我正在tomcat webserver环境中运行一个war文件。如何仅在Spring中通过注释配置组件扫描?
我有@Beans
注释基于配置,以及web服务一个XML配置:
@Configuration
//@ComponentScan(basePackageClasses = ...)
public class AppConfig {
//beans @Bean
}
的applicationContext.xml:
<beans>
<context:component-scan base-package="..."/>
<jaxws:endpoint ... />
</bean>
问题:我想定义的注释@ComponentScan
只有类型安全。但如果我这样做,扫描不会执行。相反,当我使用<context:component-scan..
一切正常。
是Spring
组件扫描绑定到XML配置的web服务器的包扫描?
http://stackoverflow.com/questions/24130166/componentscan-basepackageclasses-vs-componentscan-basepackages-to-register-a-sin – Stefan