<?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. halcon与C#混合编程

    halcon源程序: dev_open_window(0, 0, 512, 512, 'black', WindowHandle)read_image (Image, 'C:/Users/BadGuy ...

  2. Html小插件

    1.天气预报插件 效果图: 源代码: <iframe width="650" scrolling="no" height="60" f ...

  3. JqGrid使用经验

    一.更改分页组件的样式 分页组件中

  4. highlight a DOM element on mouse over, like inspect does

    highlight a DOM element on mouse over, like inspect does highlight a DOM element on mouse over, like ...

  5. 基于xml文件实现系统属性配置管理

    文章标题:基于xml文件实现系统属性配置管理 . 文章地址: http://blog.csdn.net/5iasp/article/details/11774501 作者: javaboy2012 E ...

  6. 黑马程序员_<<StringBuffer,包装类>>

    --------------------ASP.Net+Android+IOS开发..Net培训.期待与您交流! -------------------- 1. StringBuffer 1.概述 S ...

  7. HDU 1976 prime path

    题意:给你2个数n m.从n变成m最少须要改变多少次. 当中: 1.n  m  都是4位数 2.每次仅仅能改变n的一个位数(个位.十位.百位.千位),且每次改变后后的新数为素数 思路:搜索的变形题,这 ...

  8. ios数组基本用法和排序

    1.创建数组 // 创建一个空的数组 NSArray *array = [NSArray array]; // 创建有1个元素的数组 array = [NSArray arrayWithObject: ...

  9. Google Maps 学习笔记(一)2014.06.04

    1.<body onload="加载地图的函数" onunload="GUnload()"> 2.new GMap2(container,opts) ...

  10. C#复习三(Day 22)

    哈哈,又到了总结的时间了.今天还是在继续复习C#的基础语法.这次总结主要以一下小程序为主. Split()的运用 123-456---789-----123-2把类似的字符串中重复符号去掉,得到123 ...