Class A:
package myproject.web.factory.components;
@Component
public class AppComponentFactory{
}
Class 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
}
}
Configuration XML:
<context:component-scan base-package="myproject.spring" />
WebConfig.java:
package myproject.spring.config;
@Configuration
@ComponentScan(basePackages = { "myproject.web.components"})
public class WebConfig {
I have followed all the rules in http://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html:
Any ideas?
If there was no typo, I believe the correct would be
@ComponentScan(basePackages = { "myproject.web"})
since AppComponentFactory
is in myproject.web.factory
package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With