In
application.properties
we have the line
spring.profiles.active=LOCALHOST
In
application-DEV.properties
, we have the line
spring.profiles.active=DEV,dbcache,metrics,AWS
. When running the app with
java -jar app.war -Dspring.profiles.active=DEV
the console output says
The following profiles are active: LOCALHOST
, ie the
-Dspring.profiles.active=DEV
argument isn't honored, the app still uses the default LOCALHOST profile.
My man page for the java
command says:
java [ options ] -jar file.jar [ argument ... ]
That is, JVM options (such as property settings) must go before the -jar
(or main class). Anything after that is considered an argument passed to main
.
This actually has a purpose and isn't just pedantic--you might have a tool that launches a child JVM (Maven can do this, for example) and want to provide arguments to be passed there.