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引入基本的依赖即可. 那么多数据源的原理呢? ...
随机推荐
- (LeetCode 72)Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2 ...
- Discuz常见小问题-如何设置163邮箱注册验证
参考网址: https://jingyan.baidu.com/album/c843ea0b804a6e77931e4aa7.html?picindex=3 http://www.discuz.net ...
- es5 - array - join
/** * join描述:将数组(或类数组对象)的所有元素连接到一个字符串中并返回此字符串. * join语法:arr .join([ separator]) * join参数:指定用于分隔数组的每对 ...
- 安卓手机使用Fiddler抓获HTTPS报文方法
Configure Fiddler Click Tools > Fiddler Options > Connections. Ensure that the checkbox by All ...
- java程序设计题库
选择题 答题要求:单选题,每题只有一个正确答案,选择正确给分,不正确不给分. 1. 下面( A )数据类型可用于main()方法中传递的参数 A.String B.Integer C ...
- Python 默认参数
定义默认参数 定义函数的时候,还可以有默认参数. 例如Python自带的 int() 函数,其实就有两个参数,我们既可以传一个参数,又可以传两个参数: >>> int('123') ...
- LOL 战斗力查询
LOL(英雄联盟) 战斗力查询 接口:http://lolbox.duowan.com/playerDetail.php?serverName=serverName&playerName=pl ...
- Mongoose使用——nodejs结合mongodb
0. 前言: Mongoose是NodeJS的驱动,不能作为其他语言的驱动.Mongoose有两个特点: 通过关系型数据库的思想来设计非关系型数据库 基于mongodb驱动,简化操作 Mongooos ...
- Android 四大组件(Activity、Service、BroadCastReceiver、ContentProvider)
转载于:http://blog.csdn.net/byxdaz/article/details/9708491 http://blog.csdn.net/q876266464/article/deta ...
- Docker的安装使用-第1章
Docker的安装 1.1 环境说明 操作系统: Red Hat Enterprise Linux Server release 7.1 软件环境: 系统已经配置了yum安装源 软件版本: docke ...