Spring加载指定环境的配置文件

来源:互联网 发布:mac是哪个国家 编辑:程序博客网 时间:2024/04/24 04:51

1、Web.xml,配置使用哪种环境信息,tomcat启动的时候自动去加载对应的环境信息

       <display-name>显示名称</display-name>    <!-- spring服务层的配置文件  --><!-- 指定系统环境  --><context-param>        <param-name>spring.profiles.active</param-name>        <!--<param-value>${profiles.activation}</param-value>-->
       <param-value>deploy</param-value>
</context-param><context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:spring/*.xml</param-value></context-param>



2、Sping.xml配置加载/config/config.propertiess

<beans profile="deploy"><bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">        <property name="locations">            <list>                <value>file:/config/config.propertiess</value>                            </list>        </property>        <property name="fileEncoding" value="UTF-8" />    </bean>            </beans>


















0 0
原创粉丝点击