I am not using Spring Boot. I have a plain Spring Framework application.
I have a Spring integration test written with SpringJUnitConfig
.
I am using PropertySourcesPlaceholderConfigurer
.
By default Spring Environment
properties are searched last with PropertySourcesPlaceholderConfigurer
.
How can I use PropertySourcesPlaceholderConfigurer
in tests and make it search Java System Properties before all other properties?
As described in the PropertySourcesPlaceholderConfigurer
‘s Javadoc, one needs to manipulate the Environment
before the test is executed. But how can I do this?
2
You probably don’t want to change the order, but use @TestPropertySource instead. These have a higher precedence than system properties.
See Context Configuration with Test Property Sources for how to do that without Spring Boot.