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:
- Only one method can be annotated with this annotation.
- The method MUST NOT have any parameters except in the case of EJB interceptors
- The return type of the method MUST be void.
- The method MUST NOT throw a checked exception.
- The method on which PostConstruct is applied MAY be public, protected, package private or private.
- The method MUST NOT be static .
Any ideas?