Hi all
I'm using Spring code based configuration to setup my webapp which works fine.
Initializer:
Configuration:Code:public class AppInit implements WebApplicationInitializer { @Override public void onStartup(final ServletContext container) { // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppConfig.class); // Manage the lifecycle of the root application context container.addListener(new ContextLoaderListener(rootContext)); container.addListener(new RequestContextListener()); container.addListener(new Log4jConfigListener()); // Add filters // TODO: Need configuration values here } }
What I'm trying to do now is configuring my filters with properties from the same source as @PropertySource("${applicationConfigLocation}").Code:@Configuration @ComponentScan(basePackages = "package") @PropertySource("${applicationConfigLocation}") // importing other configuration classes // ... public class AppConfig { @Bean public PropertySourcesPlaceholderConfigurer pspc() { return new PropertySourcesPlaceholderConfigurer(); } }
${applicationConfigLocation} is defined in the context of the web application and points to some property file in the classpath.
Is there any good/clean way to do this? Something like telling Spring to load the configuration already in WebApplicationInitializer#onStartup? If possible, I'd like to prevent manually loading the property file..
Cheers
- Ada


Reply With Quote
