zoukankan      html  css  js  c++  java
  • 【转】 利用spring的profile切换不同的环境

                <?xml version="1.0" encoding="UTF-8"?>  
                <beans xmlns="http://www.springframework.org/schema/beans"  
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
                    xmlns:aop="http://www.springframework.org/schema/aop"  
                    xsi:schemaLocation="http://www.springframework.org/schema/beans   
                    http://www.springframework.org/schema/beans/spring-beans.xsd   
                    http://www.springframework.org/schema/context   
                    http://www.springframework.org/schema/context/spring-context.xsd   
                    http://www.springframework.org/schema/aop   
                    http://www.springframework.org/schema/aop/spring-aop.xsd">  
                  
                    <!-- 自动扫描 -->  
                <!--     <context:component-scan base-package="com.wei" /> -->  
                    <import resource="spring-dao.xml" />  
                    <import resource="spring-service.xml" />  
                    <import resource="spring-mvc.xml" />  
                    <import resource="spring-cxf.xml" />  
                    <beans profile="dev"  >  
                        <context:property-placeholder location="classpath*:jdbc-dev.properties" />  
                    </beans>  
                    <beans profile="sit"  >  
                        <context:property-placeholder location="classpath*:jdbc-sit.properties" />  
                    </beans>  
                </beans> 

      web.xml配置如下:

                <?xml version="1.0" encoding="UTF-8"?>  
                <beans xmlns="http://www.springframework.org/schema/beans"  
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
                    xmlns:aop="http://www.springframework.org/schema/aop"  
                    xsi:schemaLocation="http://www.springframework.org/schema/beans   
                    http://www.springframework.org/schema/beans/spring-beans.xsd   
                    http://www.springframework.org/schema/context   
                    http://www.springframework.org/schema/context/spring-context.xsd   
                    http://www.springframework.org/schema/aop   
                    http://www.springframework.org/schema/aop/spring-aop.xsd">  
                  
                    <!-- 自动扫描 -->  
                <!--     <context:component-scan base-package="com.wei" /> -->  
                    <import resource="spring-dao.xml" />  
                    <import resource="spring-service.xml" />  
                    <import resource="spring-mvc.xml" />  
                    <import resource="spring-cxf.xml" />  
                    <beans profile="dev"  >  
                        <context:property-placeholder location="classpath*:jdbc-dev.properties" />  
                    </beans>  
                    <beans profile="sit"  >  
                        <context:property-placeholder location="classpath*:jdbc-sit.properties" />  
                    </beans>  
                </beans> 
  • 相关阅读:
    HDU1542 Atlantis(矩形面积并)
    HDU4784 Dinner Coming Soon(dp)
    1023: [SHOI2008]cactus仙人掌图(DP+单调队列优化)
    BZOJ 1004: [HNOI2008]Cards(群论)
    BZOJ USACO 银组 水题集锦
    BZOJ 3401: [Usaco2009 Mar]Look Up 仰望(离线+平衡树)
    BZOJ 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)
    BZOJ 3208: 花神的秒题计划Ⅰ
    BZOJ 2456: mode(乱搞)
    BZOJ 2424: [HAOI2010]订货(费用流)
  • 原文地址:https://www.cnblogs.com/zdd-java/p/6214104.html
Copyright © 2011-2022 走看看