<?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>

【转】 利用spring的profile切换不同的环境的更多相关文章

  1. 使用maven的profile切换项目各环境的参数

    Java后端开发经常需要面对管理多套环境,一般有三种环境:开发,测试,生产. 各个环境之间的参数各不相同,比如MySQL.Redis等不同环境的host不一样,若每个环境都手动替换环境很容易出错,Ma ...

  2. 利用Spring.Net技术打造可切换的分布式缓存读写类

    利用Spring.Net技术打造可切换的Memcached分布式缓存读写类 Memcached是一个高性能的分布式内存对象缓存系统,因为工作在内存,读写速率比数据库高的不是一般的多,和Radis一样具 ...

  3. 利用Spring的AbstractRoutingDataSource解决多数据源的问题【代码手动切换,非AOP】

    转: 利用Spring的AbstractRoutingDataSource解决多数据源的问题 多数据源问题很常见,例如读写分离数据库配置. 原来的项目出现了新需求,局方要求新增某服务器用以提供某代码, ...

  4. 【转】Spring Boot Profile使用

    http://blog.csdn.net/he90227/article/details/52981747 摘要: spring Boot使用@Profile注解可以实现不同环境下配置参数的切换,任何 ...

  5. spring的Profile使用对比和应用场景分析

    spring中存在这样一个功能,通过Profile来选择不同环境下的不同配置,说白了,就是通过设置一个参数来选择使用不同的数据,这个数据可能是一个bean,可能是一个xml文件,也有可能是一个prop ...

  6. 从.Net到Java学习第五篇——Spring Boot &&Profile &&Swagger2

    从.Net到Java学习系列目录 刚学java不久,我有个疑问,为何用到的各种java开源jar包许多都是阿里巴巴的开源项目,为何几乎很少见百度和腾讯?不是说好的BAT吗? Spring Boot 的 ...

  7. 利用Spring Boot+zxing,生成二维码还能这么简单

    在网站开发中,经常会遇到要生成二维码的情况,比如要使用微信支付.网页登录等,本文分享一个Spring Boot生成二维码的例子,这里用到了google的zxing工具类. 本文目录 一.二维码简介二. ...

  8. Spring+Mybatis动态切换数据源

    功能需求是公司要做一个大的运营平台: 1.运营平台有自身的数据库,维护用户.角色.菜单.部分以及权限等基本功能. 2.运营平台还需要提供其他不同服务(服务A,服务B)的后台运营,服务A.服务B的数据库 ...

  9. 带事务管理的spring数据库动态切换

    动态切换数据源理论知识 项目中我们经常会遇到多数据源的问题,尤其是数据同步或定时任务等项目更是如此:又例如:读写分离数据库配置的系统. 1.相信很多人都知道JDK代理,分静态代理和动态代理两种,同样的 ...

随机推荐

  1. printf不同格式表示法

    格式代码 A ABC ABCDEFGH %S A ABC ABCDEFGH %5S ####A ##ABC ABCDEFGH %.5S A ABC ABCDE %5.5S ####A ##ABC AB ...

  2. NET Core环境并创建运行ASP.NET网站

    kungge 在Windows系统搭建.NET Core环境并创建运行ASP.NET网站 微软于6月27日在红帽DevNation峰会上 正式发布了.NET Core 1.0.ASP.NET 1.0和 ...

  3. Android 4.0 ProGuard 代码混淆 以及 proguard returned with error code 1.See console异常的解决方法

    最近呢说要上线,就去找了下上线的方法...之前做过代码混淆,用的是progarud.cfg,但是呢自己反编译了之后还是无效,然后就丢着先不管了,因为实在不知道什么情况.今天来上线的时候结果总是报错,总 ...

  4. iOS开发中,应用内直接跳转到Appstore

    iOS开发中,应用内直接跳转到Appstore 1.进入appstore中指定的应用NSString *str = [NSString stringWithFormat:                ...

  5. 获取ubuntu 的root密码,告别sudo

    刚刚开始使用ubuntu的朋友可能知道一个提权命令    sudo 如果你接触过其他的Linux系统的话,你会知道  linux系统有一个最高权限   root.一般用su root,然后输入密码就可 ...

  6. Migration data on SQL

    从表里面导出数据XML: -- export declare @xml xml set @xml = (select * from ( select TableName = 'Schema', xml ...

  7. [Jobdu] 题目1367:二叉搜索树的后序遍历序列

    题目描述: 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. 输入: 每个测试案例包括2行: 第一行为1个整数 ...

  8. c语言中的字符数组与字符串

    1.字符数组的定义与初始化 字符数组的初始化,最容易理解的方式就是逐个字符赋给数组中各元素. char str[10]={ 'I',' ','a','m',' ',‘h’,'a','p','p','y ...

  9. 删除Lb重复的数,用La输出(顺序表)

    #include<stdio.h> typedef int A; const int LIST_INIT_SIZE=100; const int LISTINCRMENT=10; type ...

  10. BZOJ 3916: [Baltic2014]friends( hash )

    字符串哈希..然后枚举每一位+各种判断就行了 ----------------------------------------------------------------------------- ...