【发布时间】:2015-04-27 19:02:47
【问题描述】:
我的目标是使 SpringApplicationContext.xml 和所有特定于环境的属性文件脱离 war 文件,从而使 war 文件与环境无关。
1.外部化属性文件: 我想我需要做这样的事情..
<property name="searchSystemEnvironment" value="true" />
<property name="locations">
<list>
<value>file:///${MY_ENV_VAR_PATH}/my.app.config.properties</value>
</list>
</property>
这里也有讨论,how to read System environment variable in Spring applicationContext
2。 Externalize SpringApplicationContext.xml:我可能会使用外部化配置的 Spring boots 功能。
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
Q1:作为 Spring boot 的新手,我不确定是否可以安全地删除/取消选择 Spring boot 附带的所有不必要的功能并将它们应用到我的项目中?我看到 Spring boot 适用于从头开始的项目,就我而言,我正在从事一个成熟的项目。
Q2:外部化配置是一种反模式吗?我的上述方法是否朝着正确的方向前进?
【问题讨论】:
标签: xml spring spring-mvc spring-boot