-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Consider spring.profiles.default when processing configuration files #15994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can't set |
If that default profile cannot be set from a configuration file at all, the value obtained through ctx.getEnvironment().getDefaultProfiles() should not reflect such value either. Yet, it returns profile1 value (see output above). This doesn't seem to be exactly consistent. On the other hand, if the default profile can be set from a configuration, but loading of additional configuration files is then handled differently, this should be documented. |
I didn't say that it could not be set, but that it cannot be set and have its value affect the loading of other configuration files.
This is out of Boot's control as it's done in Spring Framework after config file processing has completed. The first time
We already document the use of |
Thanks for your patience and thorough explanation. It's really appreciated. I have to admit that this half-way behaviour (profile being reported other than one used for property loading) still sounds like a bug to me, but not worth pursuing anymore. In terms of what got me there: I think that at least in my case the original misleading information came most likely from here: which is non-official source, but happens to be very high on the list if you google "spring boot default profile". Considering that practically identical report existed before (I searched for duplicates in "Open" issue only, so I missed it), it's likely that I'm not the last person to hit this. |
@janotav ~ If you want to add 'support' for a default profile you could take a look at how jHipster implements a default profile... They set the default profile at SpringApplication startup by using a DefaultProfileUtil... |
This should work with the changes we've made to processing of configuration files and profiles in 2.4.x. |
I believe that spring.profiles.default property does not work as documented.
Let's consider following two application property files:
application.properties:
spring.profiles.default=profile1
application-profile1.properties:
server.servlet.context-path=/foo
And corresponding application that simply prints server.servlet.context-path and profile values:
When run without parameters, I get:
When run with explicitly selecting profile1 on command line with --spring.profiles.active=profile1, I get:
My expectation is that in the first (parameter-less) execution, context-path would be /foo because profile1 properties are loaded as default.
The text was updated successfully, but these errors were encountered: