spring.profiles.active not honoured

fred picture fred · Dec 23, 2016 · Viewed 9.9k times · Source

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.

Answer

ExploreEv picture ExploreEv · Jul 27, 2019

Just in case some one is having the same issue as me, make sure your main class args is passed into spring. Hope it helps.

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}