0

I made trivial Spring Boot application and packaged it as JAR. When I call

java  -jar target/boot-active-include-0.0.1-SNAPSHOT.jar

I got

No active profile set, falling back to default profiles: default

When I call

echo spring.profiles.include=B > application.properties 
java  -jar  target/boot-active-include-0.0.1-SNAPSHOT.jar

I got

The following profiles are active: B

When I call

rm application.properties
java -Dspring.profiles.include=B -jar target/boot-active-include-0.0.1-SNAPSHOT.jar

I got

No active profile set, falling back to default profiles: default

But I expect The following profiles are active: B

Can I include Spring profile from command line?

Version: 1.5.1.RELEASE

PS. spring.profiles.active works as expected. But I don't want replace active profiles.

2

1 Answer 1

1

I see what's happening now, and I think it's arguably something I missed when making this change.

Prior to that change, spring.profiles.include was only considered when it was used in a configuration file. Following that change, spring.profiles.include is now considered from any source (System properties, command line arguments, etc) as long as spring.profiles.active is also set.

You can see this by running your sample with both properties set:

java -Dspring.profiles.include=alpha -Dspring.profiles.active=bravo -jar target/boot-active-include-0.0.1-SNAPSHOT.jar

Both the alpha and bravo profiles are active:

2017-02-09 11:30:49.467  INFO 40409 --- [           main] my.Example                               : The following profiles are active: alpha,bravo

I've opened an issue so that we can straighten this out.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.