[英]Spring: @PostConstruct is not called
A類:
package myproject.web.factory.components;
@Component
public class AppComponentFactory{
}
B級
package myproject.web.components;
import myproject.web.factory.components.AppComponentFactory;
@Component
public class AdminTabSheet{
@Autowired
private AppComponentFactory appComponentFactory;
public AdminTabSheet() {
}
@PostConstruct
public void init() {
// does something with appComponentFactory
}
}
配置XML:
<context:component-scan base-package="myproject.spring" />
WebConfig.java:
package myproject.spring.config;
@Configuration
@ComponentScan(basePackages = { "myproject.web.components"})
public class WebConfig {
我遵守了http://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html中的所有規則:
有任何想法嗎?
如果沒有錯字,我相信正確的是
@ComponentScan(basePackages = { "myproject.web"})
因為AppComponentFactory
位於myproject.web.factory
包中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.