Maven 的构建之 pom文件一些属性分析
2017-08-06 20:31
190 查看
1 Maven 属性:
属性的引用很简单,即属性名,Maven有很多内置属性,如{basedir},表示项目根目录但是用的最多的还是自定义属性。
自定义属性也很简单,在<properties/>标签里面定义即可。
2 Maven Profile
不同环境需要不同的配置,所以Maven引入了Profile的概念。Profile的原意是轮廓,Maven就是通过不同的Profile来选择构建项目轮廓。
[html] view plain copy print?<profiles>
<profile>
<id>dev</id>
<properties>
<db.driver>…</db.driver>
<db.url>…</db.url>
<db.username>…</db.username>
<db.password>…</db.password>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<db.driver>…</db.driver>
<db.url>…</db.url>
<db.username>…</db.username>
<db.password>…</db.password>
</properties>
</profile>
</profiles>
Maven通过命令行激活Profile,使用-P参数,如mvn clean install -Ptest
我们可以使用如下方式来选择默认激活的Profile的方式:
<activation>
<activeByDefault>true</activeByDefault>
</activation>
当存在其它激活方式的时候,默认激活失效。
属性的引用很简单,即属性名,Maven有很多内置属性,如{basedir},表示项目根目录但是用的最多的还是自定义属性。
自定义属性也很简单,在<properties/>标签里面定义即可。
2 Maven Profile
不同环境需要不同的配置,所以Maven引入了Profile的概念。Profile的原意是轮廓,Maven就是通过不同的Profile来选择构建项目轮廓。
[html] view plain copy print?<profiles>
<profile>
<id>dev</id>
<properties>
<db.driver>…</db.driver>
<db.url>…</db.url>
<db.username>…</db.username>
<db.password>…</db.password>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<db.driver>…</db.driver>
<db.url>…</db.url>
<db.username>…</db.username>
<db.password>…</db.password>
</properties>
</profile>
</profiles>
<profiles> <profile> <id>dev</id> <properties> <db.driver>...</db.driver> <db.url>...</db.url> <db.username>...</db.username> <db.password>...</db.password> </properties> </profile> <profile> <id>test</id> <properties> <db.driver>...</db.driver> <db.url>...</db.url> <db.username>...</db.username> <db.password>...</db.password> </properties> </profile> </profiles>
Maven通过命令行激活Profile,使用-P参数,如mvn clean install -Ptest
我们可以使用如下方式来选择默认激活的Profile的方式:
<activation>
<activeByDefault>true</activeByDefault>
</activation>
当存在其它激活方式的时候,默认激活失效。
相关文章推荐
- Maven 的构建之 pom文件一些属性分析
- Maven 的构建之 pom文件一些属性分析
- SpringMVC构建REST接口:第二篇 配置Maven的pom.xml文件
- Maven 构件工程的属性文件-----pom.xml文件
- eclipse构建maven项目,以及创建完成后pom文件报错
- maven构建ssm项目之pom文件配置(一)
- Maven super Pom中定义的一些属性
- Maven项目中在xxx.xml ,xxx.properties 中为什么能使用 ${} 来引用pom文件中的属性
- 使用maven构建ssm项目的pom文件
- maven(4)------maven核心pom.xml文件常用元素分析
- maven 构建项目时 java路径下配置属性文件相关
- maven(4)------maven核心pom.xml文件常用元素分析
- Maven构建SSH项目pom文件依赖包
- Maven项目中pom文件分析
- Maven构建SSM框架JavaWeb项目pom.xml文件整理
- Maven的pom文件中依赖的 <classifier>属性
- maven构建pom.xml文件理解
- Maven项目中pom文件分析
- Maven-pom文件内置属性
- Maven项目中pom文件分析