【转】 利用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>
【转】 利用spring的profile切换不同的环境的更多相关文章
- 使用maven的profile切换项目各环境的参数
Java后端开发经常需要面对管理多套环境,一般有三种环境:开发,测试,生产. 各个环境之间的参数各不相同,比如MySQL.Redis等不同环境的host不一样,若每个环境都手动替换环境很容易出错,Ma ...
- 利用Spring.Net技术打造可切换的分布式缓存读写类
利用Spring.Net技术打造可切换的Memcached分布式缓存读写类 Memcached是一个高性能的分布式内存对象缓存系统,因为工作在内存,读写速率比数据库高的不是一般的多,和Radis一样具 ...
- 利用Spring的AbstractRoutingDataSource解决多数据源的问题【代码手动切换,非AOP】
转: 利用Spring的AbstractRoutingDataSource解决多数据源的问题 多数据源问题很常见,例如读写分离数据库配置. 原来的项目出现了新需求,局方要求新增某服务器用以提供某代码, ...
- 【转】Spring Boot Profile使用
http://blog.csdn.net/he90227/article/details/52981747 摘要: spring Boot使用@Profile注解可以实现不同环境下配置参数的切换,任何 ...
- spring的Profile使用对比和应用场景分析
spring中存在这样一个功能,通过Profile来选择不同环境下的不同配置,说白了,就是通过设置一个参数来选择使用不同的数据,这个数据可能是一个bean,可能是一个xml文件,也有可能是一个prop ...
- 从.Net到Java学习第五篇——Spring Boot &&Profile &&Swagger2
从.Net到Java学习系列目录 刚学java不久,我有个疑问,为何用到的各种java开源jar包许多都是阿里巴巴的开源项目,为何几乎很少见百度和腾讯?不是说好的BAT吗? Spring Boot 的 ...
- 利用Spring Boot+zxing,生成二维码还能这么简单
在网站开发中,经常会遇到要生成二维码的情况,比如要使用微信支付.网页登录等,本文分享一个Spring Boot生成二维码的例子,这里用到了google的zxing工具类. 本文目录 一.二维码简介二. ...
- Spring+Mybatis动态切换数据源
功能需求是公司要做一个大的运营平台: 1.运营平台有自身的数据库,维护用户.角色.菜单.部分以及权限等基本功能. 2.运营平台还需要提供其他不同服务(服务A,服务B)的后台运营,服务A.服务B的数据库 ...
- 带事务管理的spring数据库动态切换
动态切换数据源理论知识 项目中我们经常会遇到多数据源的问题,尤其是数据同步或定时任务等项目更是如此:又例如:读写分离数据库配置的系统. 1.相信很多人都知道JDK代理,分静态代理和动态代理两种,同样的 ...
随机推荐
- pandas的札记
导入导出数据 在导入,导出DataFrame数据时,会用到各种格式,分为 to_csv ;to_excel;to_hdf;to_sql;to_json;to_msgpack ;to_html;to_g ...
- 共享内存(shared memory)
共享内存指在多处理器的计算机系统中,可以被不同中央处理器(CPU)访问的大容量内存.由于多个CPU需要快速访问存储器,这样就要对存储器进行缓存(Cache). 任何一个缓存的数据被更新后,由于其他处理 ...
- 五年26个版本:Linux系统内核全程回顾
Phoronix.com今天将他们对Linux系统的研究发挥到了极致:从2005年年中的2.6.12,到正在开发中的2.6.37,五年多来的26个Linux内核版本来了个“群英荟萃”! 完成如此庞大规 ...
- PCB流程-外型加工
- Qt中如果通过QStyle自定义能够跨平台的界面控件
我们经常会碰到需要定制界面控件的要求.如果只是在一个平台上,比如说你的控件只需要在Windows上显示,那很好办,Hard code 你的look and feel就可以了.但是如果界面需要在不同平台 ...
- nat123外网SSH访问内网LINUX的N种方法
一,动态公网IP环境 1,环境描述: 路由器分配的是动态公网IP,且有路由管理权限,LINUX主机部署在路由内网.如何实现外网SSH访问内网LINUX主机? 2,解决方案: 使用nat123动态域名解 ...
- 九一八-->我逝去的青春
九一八纪念馆 十二年前 30元一张门票 我毫不犹豫掏钱进去参观 你们笑我 钱少人傻 在东北的四年 从2001到2005 每年都感慨这一天 北国的秋色里 警钟长鸣 长鸣声中 有我逝去的青春 如今 三十而 ...
- [置顶] .NET下枚举类型的Save和Load分析
今天在写代码的时候,心血来潮对原来的字符串保存状态位的方式很不满意,对于代码里出现了 state == "1" 这样的状态判断很是不爽.那么理想中的判断是怎样的呢?很简单如你所想枚 ...
- C++时间获取
http://net.pku.edu.cn/~yhf/linux_c/function/04.html asctime(将时间和日期以字符串格式表示) 相关函数 time,ctime,gmtime ...
- string模板
string模块中包含了一个很有用的Template类,可以先写好字符串模板,后期使用的时候直接替换就可以了. 模板中使用$作为占位符前缀,使用{}包裹占位符以支持间断的标量名,使用$ ...