码迷,mamicode.com
首页 > 编程语言 > 详细

spring.profiles.active 针对多种启动环境的spring配置

时间:2018-02-12 18:41:32      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:files   自动   文件   span   配置使用   property   name   spring   tom   

使用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

spring.profiles.active 针对多种启动环境的spring配置

标签:files   自动   文件   span   配置使用   property   name   spring   tom   

原文地址:https://www.cnblogs.com/zhao-gang/p/8445139.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!