Issue
In my StandardSpringConfiguration I have a value that is used to change the location of the props file (config.location).
@Configuration
@Retention(RUNTIME)
@PropertySource("classpath:someprops.properties")
@PropertySource(value="file:${config.location:.}/someprops.properties", ignoreResourceNotFound=true)
@ComponentScan(basePackages = "some.package")
public @interface StandardSpringConfiguration { }
Everything worked fine with spring 5.1.6.RELEASE. The issues started when I switched to spring 5.3.1.
In the past I could change the location of the prop like this:
java -jar -Dconfig.location=/somepath/resources someJar.jar --command --option AA
After changing the spring version the -Dconfig.location is ignored and it will use the default prop file. I tried to get the value of config.location and print it and it prints the correct path introduced in the terminal. Got the value like this:
@Value("${config.location}") String configLocation
Changing a single value from the prop file still works. For exapmle this will work:
java -jar -Ddb_user=SOME_USER someJar.jar --command --option AA
Has anyone encountered such issues with more recent versions of spring?
Solution
Found the answer.
The locations must be added as an array now.
@PropertySource(value = {"classpath:someprops.properties","file:${config.location:.}/someprops.properties"}, ignoreResourceNotFound=true)
Answered By - Dinu Nicolae
Answer Checked By - Timothy Miller (JavaFixing Admin)