[英]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.