maven profile 的作用
2024-10-21 07:41:32
maven 的profile 可以是我们通过编译时指定 -P 来实现 使用不同的 属性变量。
比如:
<profiles>
<profile>
<id>local</id>
<properties>
<xx>我是local环境的xx的值</xx>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<xx>我是dev的xx的值</xx>
</properties>
</profile>
</profiles>
xx 等同于属性值
<properties>
<xx>fdsfdsfds</xx>
</properties>
但是 这个时候 有了指定不同 -P 使用不同配置的功能。
所有在maven pom 文件中 可配置的 参数都可以 通过这种方式 配置 不同场景下使用不同的 参数。
比如: 可以使用profiles 配置不同镜像地址 。 这样就可以区分仓库了。
注意事项: maven 的 setting.xml 和 项目 pom.xml 中配置的 profile 会同时存在。在 -P 的时候可以使用多个 如: -P dev, devParam 逗号分割
<profile>
<id>dev</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://url/repository/maven-public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>uat</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://url/repository/maven-public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles> <activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
最新文章
- js get browser vertion (js获取浏览器信息版本)
- 洛谷P3388 【模板】割点
- Why does this json4s code work in the scala repl but fail to compile?
- AxureRP8实战手册(基础1-10)
- A+Bproblem
- java 导入包(误区)
- angular-xeditable
- Mysql中将查询出来的多列的值用逗号拼接
- MVC项目总结(别人的好文章)
- Java 国际化 语言切换
- 【集训笔记】归纳与递推【HDOJ1297
- EasyUI - ComboBox 下拉组件
- 基于TI CC2650的IPv6 over BLE(BLEach) demo
- mysql存储过程游标使用
- 启动tomcat时报错:http-nio-8080-exec-10
- (29)Why Earth may someday look like Mars
- Android性能优化9-ANR完全解析
- 环境准备——之Jdk安装
- angular.copy(source, destination)
- JavaScript数据类型(第一天)