1. 程式人生 > >spring.profiles.active 針對多種啟動環境的spring配置

spring.profiles.active 針對多種啟動環境的spring配置

ttr 配置使用 log nbsp files location .profile 環境 param

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