timomeinen
timomeinen

Reputation: 3320

Why is run.profiles getting ignored with spring-boot:run?

Using spring-boot-maven-plugin version 1.5.9.RELEASE. The documentation states using -Drun.profiles to activate the active profiles. But running on the command line the profile is not activated:

mvn spring-boot:run -Drun.profiles=development

Using the jvmArguments parameter works and the profile is active:

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

Reference: https://github.com/spring-projects/spring-boot/issues/1095

Update:

It turned out, that the profile had been loaded correctly. Only the logging was disabled due to a conditional configuration of Logback:

In the Logback configuration I used a statement like <if condition='property("spring.profiles.active").contains("development")'>. Using the Maven plugin with -Drun.profiles does not set the system property spring.profiles.active but sets the command-line argument (--spring.profiles.active).

So, when using conditional statements in Logback only system properties and environment variables can be used.

Upvotes: 2

Views: 926

Answers (1)

Hussain
Hussain

Reputation: 1015

Ensure do you have application-development.properties file. Else create it and put your properties there. By default application.properties will be considered and executed.

Based on the profile, you have create corresponding application properties file.

Upvotes: 1

Related Questions