如何从系统变量设置Spring配置文件? [英] How to set Spring profile from system variable?
问题描述
我有一个使用另一个项目的Spring项目。每个项目都有自己的spring配置文件,使用 applicationContext.xml
和 *。properties
为每个配置文件初始化java代码。我从 args []
注入配置文件。 问题是第二个项目使用 applicationContext.xml中的env的默认配置
我无法从<\\ n注入env code> args [] 到第二个项目,我试着找一篇文章来解释Spring profile的工作原理。
I have a Spring project which uses another project. Each project has its own spring profile initialize from java code using applicationContext.xml
and *.properties
for each profile. I inject the profile from args[]
. The problem is that second project uses the default configuration for the env from the applicationContext.xml
I can not inject the env from args[]
to the second project and I tried looking for an article which will explain how Spring profile works.
- 当在
applicationContext.xml
中配置默认值时,是否存在一个层次结构,它将在该层次结构中查看配置文件? - System var是否强于
applicationContext.xml
配置? - 您认为我的挑战的最佳解决方案是什么?
- Is there a hierarchy on which it will look the profile when default is not configured at
applicationContext.xml
? - Is System var stronger than
applicationContext.xml
configuration? - What you think is the best solution to my challenge?
关于该主题甚至示例的文章将非常感谢!!
提前致谢。
Articles on that subject or even examples would be most appreciated!! Thanks in advance.
推荐答案
SPRING_PROFILES_ACTIVE是覆盖/选择Spring配置文件的环境变量
SPRING_PROFILES_ACTIVE is the environment variable to override/pick Spring profile
这篇关于如何从系统变量设置Spring配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!