spring-boot: spring.profiles.default doesn't load profile-specific properties file

Repro repo: https://github.com/kryger/spring-boot-problem-profiles (plain web app generated from http://start.spring.io with some extra logging)

src/main/resources/application.properties defines the defaults:

server.port=11111
spring.profiles.default=production

application-production.properties overrides the port:

server.port=22222

Steps to reproduce:

Active: [production]
Default: [production]
Production profile ON
(...)
Tomcat started on port(s): 22222/http

That’s what I expect, but since I defined production profile to be default if none other specified, I should be able to skip this flag? Let’s…

  • …do mvn spring-boot:run on CLI, output is:
Active: []
Default: [production]
Production profile ON
(...)
Tomcat started on port(s): 11111/http

Result: production profile enabled but port specified in application-production.properties is ignored. This seems to suggest that profile-specific properties are not loaded and evaluated if they’re included as a result of defaults? Unless my understanding of what “default” means this looks like a bug, doesn’t it?

(note that moving application-production.properties to src/main/resources makes no difference)

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 26 (10 by maintainers)

Commits related to this issue

Most upvoted comments

You can’t change the default profile by declaring it in a config file. It has to be in place before the config files are read.