1
votes

I am running my jar in the following way in unix

java -jar $classpath --spring.config.location=application.yml

And I am also using a properties file which I am configuring the following way:

@PropertySource("file:${DATASERVICE_PROPERTIES}")

Both application.yml and DATASERVICE_PROPERTIES have property

server.port

I want to use the server.port in application.yml.

I thought properties supplied via commandline has highest precedence(from below link), so why is server.port from DATASERVICE_PROPERTIES taken?

Spring Boot and multiple external configuration files

1

1 Answers

0
votes

Properties supplied via command line override properties in src/main/resources/application.properties and in config/application.properties Since you are specifying in the code the file to use this doesn't apply. Why aren't you using on of the two property file location above ? So you can remove your @PropertySource and your will be able to override your properties via command line .