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> 
  • 相关阅读:
    python3初识selenium
    [lucene系列笔记3]用socket把lucene做成一个web服务
    [lucene系列笔记2]在eclipse里初步使用lucene的索引和查询功能
    [lucene系列笔记1]lucene6的安装与配置(Windows系统)
    JAVA SOCKET
    Python3 urlparse
    Windows Socket 编程_ 简单的服务器/客户端程序
    linux软件包管理
    linux用户及权限管理
    docker搭建私有仓库
  • 原文地址:https://www.cnblogs.com/zdd-java/p/6214104.html
Copyright © 2011-2022 走看看