Spring 3和JSR-330注释

时间:2013-08-05 19:28:54

标签: spring-mvc annotations

通过阅读本文Spring 3 and JSR-330 @Inject and @Named example,建议从Spring 3开始使用JSR-330的标准注释。因此,应使用@Named代替@ Component,@ Repository和@Service。但是Spring MVC中的@Controller怎么样?我知道@Controller也是@Component,在使用@Named时我的测试结果相同。但我想确定我是否遗漏了任何东西。

1 个答案:

答案 0 :(得分:0)

Spring可以使用包扫描将控制器分别连接到其他组件。

例如,可以在webmvc-config.xml中使用它:

<context:component-scan base-package="com.xxx.yyy" use-default-filters="false">
    <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

所以只需要检查项目中是否存在这样的事情。

相关问题