利用maven的filter和profile实现不同环境使用不同的配制
- 利用filter实现对资源文件(resouces)过滤
- 利用profile来切换环境
- config-dev.properties -- 开发时用
- config-test.properties -- 测试时用
- config-product.properties -- 生产时用
<build><resources><!-- 先指定 src/main/resources下所有文件及文件夹为资源文件 --><resource><directory>src/main/resources</directory><includes><include>**/*</include></includes></resource><!-- 设置对auto-config.properties,jdbc.properties进行过虑,即这些文件中的${key}会被替换掉为真正的值 --><resource><directory>src/main/resources</directory><includes><include>auto-config.properties</include><include>jdbc.properties</include></includes><filtering>true</filtering></resource></resources></build>
<profiles>
<profile>
<id>dev</id> <!-- 默认激活开发配制,使用config-dev.properties来替换设置过虑的资源文件中的${key} -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>config-dev.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>test</id>
<build>
<filters>
<filter>config-dev.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>product</id>
<build>
<filters>
<filter>config-product.properties</filter>
</filters>
</build>
</profile>
</profiles>
- 开发环境:
filter是在maven的compile阶段执行过虑替换的,所以只要触发了编译动作即可,如果像以前一样正常使用发现没有替换,则手工clean一下工程(eclipse -> Project -> Clean)【这里你应该要安装上maven插件,因为替换是maven做的,不是eclipse做的,所以这里的clean应当是触发了maven的compile】,然后在Tomcat上也右键 -> Clean一下即可,然后你去tomcat目录下会发现你的工程的资源文件里面的${key}被替换为对应的config-xx的值了
- 测试环境
手工编译,打包:maven clean install -Ptest -- 激活id="test"的profile
- 生产环境
手工编译,打包:maven clean install -Pproduct -- 激活id="product"的profile
利用maven的filter和profile实现不同环境使用不同的配制的更多相关文章
- 利用maven的resources、filter和profile实现不同环境使用不同配置文件
基本概念说明(resources.filter和profile): 1.profiles定义了各个环境的变量id 2.filters中定义了变量配置文件的地址,其中地址中的环境变量就是上面profil ...
- Maven Filter与Profile隔离生产环境与开发环境
Maven Filter与Profile隔离生产环境与开发环境 在不同的开发阶段,我们一般用到不同的环境,开发阶段使用开发环境的一套东西,测试环境使用测试环境的东西,可能有多个测试环境,生产环境使用的 ...
- Spring 环境与profile(三)——利用maven的resources、filter和profile实现不同环境使用不同配置文件
基本概念 profiles定义了各个环境的变量id filters中定义了变量配置文件的地址,其中地址中的环境变量就是上面profile中定义的值 resources中是定义哪些目录下的文件会被配置文 ...
- 利用maven的profiles灵活的配置多环境
<!--多环境配置--> <profiles> <profile> <id>dev</id> <activation> < ...
- 使用maven的profile构建不同环境配置
基本概念说明(resources.filter和profile): 1.profiles定义了各个环境的变量id 2.filters中定义了变量配置文件的地址,其中地址中的环境变量就是上面profil ...
- maven 利用 profile 进行多环境配置
我们在进行项目的多环境配置时,有很多种方式供我们选择,比如 SpringBoot 自带的 application-dev.yml.maven 的 profile 等.这里介绍的就是如何利用 profi ...
- maven学习(下)利用Profile构建不同环境的部署包
接上回继续,项目开发好以后,通常要在多个环境部署,象我们公司多达5种环境:本机环境(local).(开发小组内自测的)开发环境(dev).(提供给测试团队的)测试环境(test).预发布环境(pre) ...
- maven学习利用Profile构建不同环境的部署包
项目开发好以后,通常要在多个环境部署,象我们公司多达5种环境:本机环境(local).(开发小组内自测的)开发环境(dev).(提供给测试团队的)测试环境(test).预发布环境(pre).正式生产环 ...
- Maven 教程(18)— 利用 Profile 构建不同环境的部署包
原文地址:https://blog.csdn.net/liupeifeng3514/article/details/79776257 接上回继续,项目开发好以后,通常要在多个环境部署,象我们公司多达5 ...
随机推荐
- hexo系列教程
hexo系列教程来源: http://zipperary.com/2013/05/28/hexo-guide-1/ hexo系列教程:(一)hexo介绍 什么是hexo hexo是一个基于Node.j ...
- php函数 date() 详细资料
date_default_timezone_set(PRC); /*把时间调到北京时间,php5默认为格林威治标准时间*/ date () a: "am"或是"pm&qu ...
- 网络延迟查看器 Network latency view 1.4
这是个用于查看网络延迟/ip/主机/地区的工具,内外网通吃,外网可通过这里下载csv以显示国家(地区) 可以自己决定winpcap或者原始套接字进行捕捉 如果只扫描内网推荐angryip 这是款发布在 ...
- SQL编写
//用户表,用户ID,用户名称create table t_user (user_id int,username varchar(20));//用户帐户表,用户ID,用户余额(单位分)create t ...
- AttributeError: 'NoneType' object has no attribute 'bytes' python3.4 win64
解决方法: easy_install -U pip 详见: https://github.com/pypa/pip/issues/2669
- spring-mvc不拦截静态资源的配置
spring-mvc不拦截静态资源的配置 标签: spring 2015-03-27 23:54 11587人阅读 评论(0) 收藏 举报 版权声明:本文为博主原创文章,未经博主允许不得转载. &qu ...
- leetcode 150. Evaluate Reverse Polish Notation ------ java
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, ...
- squid代理服务器搭建及配置
系统环境:CentOS release 6.5 (Final)(最小化安装) 一.安装squid # yum -y install squid 二.编辑配置文件(正向代理) # vim /etc/sq ...
- nginx绑定多个域名
nginx绑定多个域名涉及到的技术为url rewrite,可以先了解下知识背景再过来学习. 这里以域名:www.sample.com为例 1.在/usr/local/nginx/conf文件夹中创建 ...
- hdu1285 拓扑序
题意:有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩, ...