ADN
ADN

Reputation: 65

Run Spring boot .jar file with spring.config.location with replace values of application.properties?

When I run a Spring boot application from command line with --spring.config.location=another.properties, values in another.properties will be overridden the values in application.properties ?

For example:

If there is a value spring.datasource.url in application.properties, but not in application.properties. So the value is taken from another.properties or undefined ?

Upvotes: 0

Views: 3340

Answers (1)

davidxxx
davidxxx

Reputation: 131346

It replaces.
The documentation states :

If you don’t like application.properties as the configuration file name you can switch to another by specifying a spring.config.name environment property. You can also refer to an explicit location using the spring.config.location environment property (comma-separated list of directory locations, or file paths).

Now, nobody prevents you from declaring multiple properties in spring.config.location value :

$ java -jar myproject.jar --spring.config.location=classpath:/application.properties,classpath:/another.properties

In this way, another.properties overrides properties also present in application.properties.

Upvotes: 2

Related Questions