Reputation: 523
I want to externalize my configuration with Spring Boot, but I want to continue to partially use my xml context.
My main class SpringServerApplication.java :
@Configuration
@PropertySources(value = {@PropertySource("classpath:/application.properties")})
public class SpringServerApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(new Object[] {
SpringServerApplication.class, "classpath:ApplicationContextServer.xml" }, args);
}
}
I put my configuration in application.properties.
And in ApplicationContextServer.xml, I want to use some parameter like this : ${user}.
But it does not work. Thanks in advance for your help.
Upvotes: 1
Views: 5423
Reputation: 124471
Remove the @PropertySource
as that is already done by Spring Boot, instead add @EnableAutoConfiugration
and use @ImportResource
to import your xml config files.
@Configuration
@EnableAutoConfiguration
@ImportResource("classpath:ApplicationContextServer.xml")
public class SpringServerApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(new Object[] {SpringServerApplication.class}, args);
}
}
That should be enough to do what you want. Depending on the content in your xml file you might even be able to drop some of it (as Spring Boot can quite easily do auto configuration of resources for you).
Upvotes: 2
Reputation: 957
Use <context:property-placeholder/>
in applicationContext.xml
And import xml based configuration like this:
@ImportResource({"classpath*:applicationContext.xml"})
Upvotes: 0