我们的工程一般在会跑在正式环境、测试环境上,当打包或者运行的时候,切换数据库信息可能会是很麻烦的问题。
配置方式:
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>
---------------------
作者:leo_perfect
来源:CSDN
原文:https://blog.csdn.net/leo_perfect/article/details/52183536
版权声明:本文为博主原创文章,转载请附上博文链接!
2、在web.xml中配置使用哪种环境信息,tomcat启动的时候自动去加载对应的环境信息
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>