Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
449 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use below props..

@PropertySource(value="file:${config.location:.}/someprops.properties", ignoreResourceNotFound=true


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...