使用spring.profiles.active 配置正式環境,測試環境
配置方式:
1、在spring配置文件中配置兩種環境信息
<beans profile="dev">
<context:property-placeholder location="classpath:jdbc-dev.properties"/>
</beans>
<beans profile="prd">
<context:property-placeholder location="classpath:jdbc-prd.properties"/>
</beans>
2、在web.xml中配置使用哪種環境信息,tomcat啟動的時候自動去加載對應的環境信息
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>