in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
Currently the key used to read Spring active profiles is named 'spring.profiles.active' and it can't be changed.
There are several use cases where making this key fully configurable would reveal highly useful.
e.g. 'myapp1_profiles_active', 'myapp2_profiles_active', 'foobar_x', etc.
One idea behind the newly introduced Spring profile feature is to be able to trigger a specific configuration in an application without changing the content of the application, just by introducing a variable that will be read by Spring at startup.
This key value can be read from the system environment variable (no additional parameter needed when starting an application) or from the java system properties, traditionally passed with -Dkey=value in the command line used to stat the application.
When you have several applications running on a single machine, such as when you work on different applications as a developer, you may quickly end up needing to pass different spring active profile values to each application.
This isn't possible with system environment variable. You can only specify different spring.profiles.active value per application through Java system properties, which can become quiet cumbersome when you have many run/debug configuration in your IDE, or when you use maven command line.
Allowing for a fully configurable key through a simple annotation, something like @ActiveProfilesPropertyName("myapp_profiles_active"), or it's equivalent in XML, would allow for a higher level of configurability.
This would be used only by the ones that need this higher level, conventional key value would apply by default.
Thanks for creating this separate issue. As I mentioned in #13510, I will leave this open in the 3.2 backlog for a while to see if there is indeed interest from others in such a feature. Without a pretty strong additional arguments and support, we won't add first-class support for something like this.
As you originally mentioned, there is a quite reasonable way of acheiving this on your own, doing something like the following from within an ApplicationContextInitializer:
it's good that you mention the ApplicationContextInitializer.
It's a quite convenient workaround for a webapp, but what would be its equivalent for a standalone application or for a test context for that matter?
I haven't been able to find something similar in the code when not in a web context.
In a standalone or other non-web application you would just work against the ApplicationContext directly. The code sample I gave above would work equally as well there. In the Spring TestContext framework, you can use the new @ActiveProfiles annotation for this purpose.
in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
1 participant
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
jean opened SPR-8875 and commented
For background, see https://jira.springsource.org/browse/SPR-8869?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=73077
Currently the key used to read Spring active profiles is named 'spring.profiles.active' and it can't be changed.
There are several use cases where making this key fully configurable would reveal highly useful.
e.g. 'myapp1_profiles_active', 'myapp2_profiles_active', 'foobar_x', etc.
One idea behind the newly introduced Spring profile feature is to be able to trigger a specific configuration in an application without changing the content of the application, just by introducing a variable that will be read by Spring at startup.
This key value can be read from the system environment variable (no additional parameter needed when starting an application) or from the java system properties, traditionally passed with -Dkey=value in the command line used to stat the application.
When you have several applications running on a single machine, such as when you work on different applications as a developer, you may quickly end up needing to pass different spring active profile values to each application.
This isn't possible with system environment variable. You can only specify different spring.profiles.active value per application through Java system properties, which can become quiet cumbersome when you have many run/debug configuration in your IDE, or when you use maven command line.
Allowing for a fully configurable key through a simple annotation, something like
@ActiveProfilesPropertyName
("myapp_profiles_active"), or it's equivalent in XML, would allow for a higher level of configurability.This would be used only by the ones that need this higher level, conventional key value would apply by default.
Reference URL: https://jira.springsource.org/browse/SPR-8869?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=73077
1 votes, 2 watchers
The text was updated successfully, but these errors were encountered: