samedi 28 février 2015

AbstractAnnotationConfigDispatcherServletInitializer in Spring and Registration of Classes

i am converting my xml based spring app to java config and the hell break lose. I have several @config classes and my problem is the registration of MyWebConfiguration.class. This class is a child of RepositoryRestMvcConfiguration and has of course some @bean methods in it. But no @bean method is invoked, even though the registration went w/o problems.


Are there any issues when overriding both getRootConfigClasses() and getServletConfigClasses() ?


If i put the MyWebConfiguration class into getRootConfigClasses(), it will at least run those @bean methods.



public class AppInitializer extends
AbstractAnnotationConfigDispatcherServletInitializer {

...
@Override
protected final Class<?>[] getRootConfigClasses() {
return new Class[]{CoreConfiguration.class, JpaConfiguration.class,
ShiroSecurityConfig.class};
}

@Override
protected final Class<?>[] getServletConfigClasses() {
return new Class[]{MyWebConfiguration.class};
}
}


Furthermore i have severe Problems using @Resource in@Configuration classes to obtain a bean from a different configuration class. But this is just a side issue i have at the moment.


The issue with @Bean methods which wont get fired is the most serious one. Thanks for any infos.


Aucun commentaire:

Enregistrer un commentaire