Maven profiles + 资源过滤,多环境自动适配

概述

在项目开发时,会有各种开发环境,mac、linux、windows,然后开发环境、测试环境、预发布环境、生产环境,各个数据库等都不一样。
那么不可能每次发布时都要去修改对应的数据库配置,等其他相关配置。
可以用 maven 的 profiles 来实现不同环境的相关配置。

使用

1、在项目中创建下面几个文件,并在中填写自己的配置 key=value

src/main/filters/filter-dev.properties
src/main/filters/filter-test.properties
src/main/filters/filter-production.properties

2、在 pom.xml 中添加

原创文章,转载请注明: 转载自LoserZhao – 诗和远方[ http://www.loserzhao.com/ ]

本文链接地址: http://www.loserzhao.com/bigdata/maintenance/maven-profiles.html

文章的脚注信息由WordPress的wp-posturl插件自动生成

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

使用新浪微博登陆