1

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

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
user3809938
  • 1,114
  • 3
  • 16
  • 35

1 Answers1

0

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 .

Akli REGUIG
  • 552
  • 4
  • 13