Description
In reference to #2404 which has been closed...
Spring Booot, being an opinionated framework, should try as hard as possible to adhere to established standards in the industry.
Any application can have three levels of property values: Global default values, Environment default values and Instance specific values.
Profiles, by definition, are Environment default values. They should always be overridden by any instance specific property.
As I see it, you might want to ship default values both for the global settings and for environment specific settings (ie PROD, TEST etc) embeded in the application.
But any instance specific setting should always override the two latter. And, usually, instance specific settings are deployed together with the application on the server.
So to force people to use application-PROD.properties when deploying a production instance and application-TEST on a test instance, is not only wrong, but also a cause of many headaches. I have just spent an hour trying to explain to an infrastructure guy why he must add some text to the properties file based on which profile is used. He did not get it!
So instead of
- Command line arguments.
- JNDI attributes from java:comp/env.
- Java System properties (System.getProperties()).
- OS environment variables.
- A RandomValuePropertySource that only has properties in random.*.
- Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants)
- Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants)
- Application properties outside of your packaged jar (application.properties and YAML variants).
- Application properties packaged inside your jar (application.properties and YAML variants).
- @propertysource annotations on your @configuration classes.
- Default properties (specified using SpringApplication.setDefaultProperties).
we should have
- Command line arguments.
- JNDI attributes from java:comp/env.
- Java System properties (System.getProperties()).
- OS environment variables.
- A RandomValuePropertySource that only has properties in random.*.
- Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants)
- Application properties outside of your packaged jar (application.properties and YAML variants).
- Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants)
- Application properties packaged inside your jar (application.properties and YAML variants).
- @propertysource annotations on your @configuration classes.
- Default properties (specified using SpringApplication.setDefaultProperties).