利用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 ...
随机推荐
- node模拟http服务器session机制-我们到底能走多远系列(36)
我们到底能走多远系列(36) 扯淡: 年关将至,总是会在一些时间节点上才感觉时光飞逝,在平时浑浑噩噩的岁月里都浪费掉了太多的宝贵.请珍惜! 主题: 我们在编写http请求处理和响应的代码的时 ...
- python, itertools模块
通过itertools模块,可以用各种方式对数据进行循环操作 1, chain() from intertools import chain for i in chain([1,2,3], ('a', ...
- 在Python中,令values=[0,1,2];values[1]=values,为何结果是[0,[...],2]?
转载自:http://www.zhihu.com/question/21000872/answer/16856382>>> values = [0, 1, 2] >>&g ...
- 在centos使用rpm包的方式安装mysql,以及更改root密码
在centos使用rpm包的方式安装mysql,对于centos官方实际推荐使用yum进行安装,下载安装的方式主要用于内网服务器不能连接外网yum源的情况. 下载包 首先根据centos版本在mysq ...
- kafka的推和拉的问题
之前学习过这一问题,但是面试又被问道了.再次记录下 推还是拉? Kafka最初考虑的问题是,customer应该从brokes拉取消息还是brokers将消息推送到consumer,也就是pull还p ...
- Xcode7如何进行真机测试
1. 下载xcode7 可以通过访问 https://developer.apple.com/xcode/downloads/ 下载最新的xcode7的版本 2. 配置accounts 打开xcode ...
- 越狱Season 1-Episode 15: By the Skin and the Teeth
Season 1, Episode 15: By the Skin and the Teeth -Pope: doctor...you can leave. 医生你得离开 -Burrows: It's ...
- SqlAlchemy初探
SqlAlchemy是Python下的一个成熟的ORM框架.下面我们对他的使用做一个简略的介绍. 0.安装 如果有pip,使用pip安装,更便捷.pip install sqlalchemy 也可以下 ...
- HBase 建表新增数据记录
login as: root root@192.168.12.23's password: ********* Last login: Wed Aug 20 00:41:17 2014 from 19 ...
- Xcode 7安装KSImageNamed失败解决方法
## How do I use it? Build the KSImageNamed target in the Xcode project and the plug-in will automati ...