Maven使用profile 和 filtering实现多种环境下配置打包
2016-06-16 00:00
555 查看
项目开发过程中我们经常定义不同环境的配置文件,如开发环境、测试环境、生产环境。若我们使用一份配置文件在发布的时候进行手动更改,那将是一件非常麻烦痛苦的一件事,这是我们可以借助Maven轻松完成不同环境的打包工作。
1.写三份不同环境的配置文件如下:
2.修改pom.xml文件添加一下内容:
打包发布:
(1). intellij idea 方式
勾选想要打包的环境后选择package打包
(2). Eclipse方式,右键项目名,Run as ——> Run configurations ——>Maven Build ——>New
Goals: mvn clean package -Ptest
上面是打包为test环境
1.写三份不同环境的配置文件如下:
2.修改pom.xml文件添加一下内容:
<!-- 全局属性配置 --> <profiles> <!--测试环境配置--> <profile> <id>test</id> <properties> <env>test</env> <maven.test.skip>false</maven.test.skip> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> <!--发布环境配置--> <profile> <id>deploy</id> <properties> <env>deploy</env> <maven.test.skip>false</maven.test.skip> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles> <build> <resources> <resource> <directory>src/main/resources</directory> <targetPath>${project.build.directory}/classes</targetPath> <includes> <include>**/{env}/*</include> <include>*.properties</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources/${env}</directory> <targetPath>${project.build.directory}/classes</targetPath> <filtering>true</filtering> </resource> </resources> </build>
打包发布:
(1). intellij idea 方式
勾选想要打包的环境后选择package打包
(2). Eclipse方式,右键项目名,Run as ——> Run configurations ——>Maven Build ——>New
Goals: mvn clean package -Ptest
上面是打包为test环境
相关文章推荐
- 解决子pom.xml需要版本
- WeMall微商城营销技巧之一:微商怎么做?怎么找客源?
- [译]人生苦短
- 查找系统中最大文件
- 暴利的CDN即将被流量矿石模式颠覆
- tkinter的类的应用-------类的基础(六)
- 类的tkinter应用(二)--------------类的基础(七)
- 别人的python类的笔记
- python中的类的继承和dict对象------------类的基础(三)
- python中一切皆对象------类的基础(五)
- pyhon中类的复杂继承--------类的基础(八)
- 怎样制作EDIUS中的单声道音乐
- PHP:神奇的"+"
- 去除tableView的header的粘性
- 设置状态栏字体颜色为白色
- naviBar的颜色
- 横线平移动画
- 图片指定宽度按比例缩放
- 判断系统定位是否开启,判断是否开启相机访问 ,判断是否开启相册访问
- 相机相册跳转