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> 
  • 相关阅读:
    WIN2008 R2 安装SQLSERVER2008笔记
    WINFORM 打开PDF
    Android 笔记:ImageButton单击切换按钮图片效果的实现(转)
    Android笔记: 查看SDK源码
    H5结合百度map实现GPS定位
    js 计算快速统计中用到的日期
    SpringMVC4+MyBatis+SQL Server2014 基于SqlSession实现读写分离(也可以实现主从分离)
    SpringMVC4+MyBatis+SQL Server2014实现读写分离
    SpringMVC4集成ehcache
    C# 匿名类型序列化、反序列化
  • 原文地址:https://www.cnblogs.com/zdd-java/p/6214104.html
Copyright © 2011-2022 走看看