2

I have created 2 files under src/main/resources:

  • application.properties
  • application-local.properties

The first one has properties that take values from env variables, while the latter has fixed values.

According to specific here, I've launched spring boot in such way:

mvn spring-boot:run -Dspring.profiles.active=local

However no effects are produced and application-local.properties seems to be ignored.

Any hints?

Fabrizio Stellato
  • 1,727
  • 21
  • 52

3 Answers3

2

Yeah, if you're running with the spring-boot plugin, you have to pass the profile with -Dspring-boot.run.profiles, try

mvn spring-boot:run -Dspring-boot.run.profiles=local
lane.maxwell
  • 5,002
  • 1
  • 20
  • 30
1

Try this, it worked for me!

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=something"

Check if this article throws some light !

Maven spring boot run debug with arguments

Harsh
  • 812
  • 1
  • 10
  • 23
0

In the same path as the existing application.properties file, you can create 2 environment files:

application-local.properties
application-server.properties

to call local you can run this command:

$ java –jar -Dspring.profiles.active=local app.jar

or, you can directly call it in the application.properties file:

spring.profiles.active=local
samivic
  • 1,216
  • 14
  • 13