第一、资源文件位置
第二、spring配置文件中的配置
<!-- release环境 --> <beans profile="release"> <context:property-placeholder ignore-resource-not-found="true" location="classpath*:/envConf/application_release.properties"/> </beans> <!-- test环境 --> <beans profile="test"> <context:property-placeholderignore-resource-not-found="true" location="classpath*:/envConf/application_test.properties"/> </beans>
第三、spring配置文件中的配置
1)方式一
<context-param>
<param-name>spring.profiles.default</param-name>
<!-- 测试环境 -->
<param-value>test</param-value>
<!-- 正式环境 -->
<!-- <param-value>release</param-value> -->
</context-param>
2)方式二
<context-param>
<param-name>spring.profiles.active</param-name>
<!-- 测试环境 -->
<param-value>test</param-value>
<!-- 正式环境 -->
<!-- <param-value>release</param-value> -->
</context-param>