[英]How to configure component-scan by annotation only in Spring?
我在tomcat webserver環境中運行war文件。
我有一個基於注釋的@Beans
配置,以及一個用於webservices的xml配置:
@Configuration
//@ComponentScan(basePackageClasses = ...)
public class AppConfig {
//beans @Bean
}
applicationContext.xml中:
<beans>
<context:component-scan base-package="..."/>
<jaxws:endpoint ... />
</bean>
問題:我想通過注釋定義@ComponentScan
只是為了具有類型安全性。 但如果我這樣做,則不會執行掃描。 相比之下,當我使用<context:component-scan..
一切正常。
是否在Web服務器中進行Spring
組件掃描與包裝掃描的xml配置相關聯?
瀏覽http://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch06s02.html 。
@Configuration
@ComponentScan("com.company") // search the com.company package for @Component classes
@ImportXml("classpath:com/company/data-access-config.xml")
public class Config {
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.