mercredi 11 mars 2015

Why Spring's AsyncConfigurer messes up context loading order

I'm experiencing a strange behavior with Spring context initialization ordering. I have the following configuration class:



@Configuration
@ComponentScan(basePackageClasses = foo.Bar.class, useDefaultFilters = false, includeFilters = @Filter(Service.class))
@Import({ PersistenceConfig.class, SecurityConfig.class })
@EnableAsync
@EnableScheduling
public class RootConfiguration {
@PostConstruct
public void done() throws Exception {
}
}


This works just fine. My done method gets executed AFTER PersistenceConfig and ServiceConfig. But whey I make my Rootconfiguration implement AsyncConfigurer, the done method gets executed BEFORE PersistenceContext and SecurityContext, which is problematic in my case!


Any ideas of why such behavior? Is it documented somewhere?


Any insight would be greatly appreciated.


Aucun commentaire:

Enregistrer un commentaire