spring-mvc注解配置小记

Controller中注解Service时,Service的实现类需加@Service,dao的实现类需加@Repository。

另:配置文件中对应的包也需要扫描到!!!

<context:annotation-config /><!-- 启动注解 -->
<!--上下文组件扫描 包 *通配 -->
<context:component-scan base-package="cxweb.*" />

还有一个很重要。容易被忽略的:

web.xml配置中还需要加上2个监听器(顺序有要求!):

<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

以上就是spring-mvc注解配置时需要非常注意的地方,不然Controller中注解Service时注解不进来,注解不进来!!!!!!

 

posted @ 2017-12-20 11:57  ATJAVA  阅读(131)  评论(0编辑  收藏  举报