Spring Boot Profiles, Overriding Properties, and spring.profiles.include

June 20th 2020

I've been using Spring Boot for a while now, and I can't believe I didn't realize this behavior with properties and profiles before. Given an application.yml like this:

test: X

  profiles: a

test: A

  profiles: b
  profiles.include: a

test: B

Obviously if running with the "a" profile, the property test will be "A". But what happens when running with the "b" profile?

java -Dspring.profiles.active=b test.jar

The answer is again "a". In other words, when you include another profile, it overrides any properties from it over top of the active one. I always assumed that it would be the other way around, but that's not the case.

I believe that software development is fundamentally about making decisions, and so this is what I write about (mostly). In 2018 I started Highline Solutions, a consulting practice that helps companies with architecture, devops, and full-stack development. I have two degrees from Carnegie Mellon University, one in Information and Decision Systems and one in Philosophy (thesis). I live in Pittsburgh, PA with my wife and 3 energetic boys.
Got a Comment?

Comments (0)

 None so far!