Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring.profiles.active not honoured

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.

like image 640
fred Avatar asked Feb 03 '26 07:02

fred


1 Answers

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);
}
like image 68
ExploreEv Avatar answered Feb 05 '26 21:02

ExploreEv