Maven + Spring 进行多环境自动切换功能
在pom.xml的<project></project>的最下放写入如下代码:
<!-- profiles setting start [mvn install -P xxx ] 1:development 2:test 3:
production -->
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profiles.active>development</profiles.active>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<profiles.active>production</profiles.active>
</properties>
</profile>
</profiles>
在项目的web.xml中加入如下代码:
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>${profiles.active}</param-value>
</context-param>
这样就可以将Maven项目中的参数 profiles.active 传递到web.xml中去,maven这里在打包时会自动去修改web.xml中的代码,当这里为这样多环境切换之后,在spring的容器中,进行其他的环境管理直接使用
<beans profile="development">
需要写入的其他的bean,这里表示这个区域只能是配置中的东西才能访问到对应的这块代码,其他的不能访问
</beans>
Maven + Spring 进行多环境自动切换功能的更多相关文章
- Maven 整合 spring profile实现多环境自动切换
Maven 整合 spring profile实现多环境自动切换 时间:2014-03-19 15:32来源:Internet 作者:Internet 点击:525次 profile主要用在项目多环境 ...
- tabs自动切换功能的实现
<html><head><!-- Bootstrap 核心 CSS 文件 --> <link rel="stylesheet" href= ...
- html+css+jQuery+JavaScript实现tab自动切换功能
tab1.html内容 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> & ...
- 一分钟学会Spring Boot多环境配置切换
一. 问题由来 开发环境.测试环境.生产环境--------我们的软件在不同的环境中,系统参数和配置可能会不一样,比如数据源配置.日志文件配置.以及一些软件运行过程中的基本配置,那每次我们将软件部署到 ...
- maven profile多环境自动切换配置,配置分离,排除文件
痛点: 在java开发的过程中,我们经常要面对各种各样的环境,比如开发环境,测试环境,正式环境,而这些环境对项目的需求也不相同. 在此之前,我们往往需要手动去修改相对应的配置文件然后打成war,才能部 ...
- (转载)maven profile多环境自动切换配置
原文:https://www.cnblogs.com/adeng/p/7059588.html 痛点: 在java开发的过程中,我们经常要面对各种各样的环境,比如开发环境,测试环境,正式环境,而这些环 ...
- 四、Spring Boot 多数据源 自动切换
实现案例场景: 某系统除了需要从自己的主要数据库上读取和管理数据外,还有一部分业务涉及到其他多个数据库,要求可以在任何方法上可以灵活指定具体要操作的数据库.为了在开发中以最简单的方法使用,本文基于注解 ...
- cxf-rs 、spring 和 swagger 环境配置切换【github 有项目】
环境切换的目的是 准生产和生产环境切换时,只修改一个文件就可以达到效果 在spring bean 文件中 配置: <bean class="cn.zno.common.context. ...
- Spring Boot 多数据源自动切换
在Spring Boot中使用单数据源的配置很简单,我们简单回忆下:只需要在application.properties进行基本的连接配置,在pom.xml引入基本的依赖即可. 那么多数据源的原理呢? ...
随机推荐
- hdoj5645DZY Loves Balls
Problem Description DZY loves playing balls. He has n balls in a big box. On each ball there is an i ...
- 【Python】【Nodejs】下载单张图片到本地,Python和Nodejs的比较
Python版本: # 下载单张图片到本地,看用时多少 import urllib.request import datetime starttime = datetime.datetime.now( ...
- iPad Air PSD设计模板
免费下载 免费的ipad air PSD 设计,包含了3个不同颜色的外套的设计. 提供免费下载! 阅读原文:iPad Air PSD设计模板
- Mysqldump参数大全(参数来源于mysql5.5.19源码)
参数 参数说明 --all-databases , -A 导出全部数据库. mysqldump -uroot -p --all-databases --all-tablespaces , -Y ...
- iOS 去掉tabaar上面的 一条线
iOS 去掉tabaar上面的 一条线 利用一个 1像素高的图片 [[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"tr ...
- Could not find RubyGem cocoapods 错误
之前安装过一次cocoapods 后来,安装octopress,安装过一次较新版的ruby,可能是由于ruby安装,把之前的cocoapods删除了,结果使用,出现如图错误 解决: 重新安装 coco ...
- TP框架中ajax post请求时提示404
ajax post请求时提示404错误 TP框架中ajax post请求时提示404 找了半天是 控制器中方法有错误! 下次再遇到去控制器方法中找一步一步找,肯定能找到,我是单词拼错了!
- java泛型通配符?
转自:http://www.linuxidc.com/Linux/2013-10/90928.htm T 有类型 ? 未知类型 一.通配符的上界 既然知道List<Cat>并不是Lis ...
- npm发包流程
1.注册npm 账号 https://www.npmjs.com/signup 2.初始化npm项目 npm init 根据发的包进行填写: { "name": "wen ...
- Commons FileUpLoad 两种上传方式解
traditional API (传统方式) //上传路径 File file = new File("C:/upload"); //临时文件路径 File tempFile = ...