简体   繁体   English

如果激活多个配置文件,如何解决冲突的属性

[英]How are conflicting properties resolved if multiple profiles are activated

Maven profiles documentation does not mention this, and it is probably a sign of bad build process design, but are there rules for resolving conflicting properties if multiple profiles are active and they all define the same property? Maven配置文件没有提到这一点,它可能是构建过程设计不良的标志,但是如果多个配置文件处于活动状态并且它们都定义了相同的属性,是否有解决冲突属性的规则?

Im quite sure that local declaration (in the pom.xml ) would override the declaration in the settings.xml , not so sure for colocal profiles 我非常确定本地声明(在pom.xml )会覆盖settings.xml的声明,对于colocal配置文件不太确定

  • is the declaration order inside the file important? 文件里面的声明顺序重要吗?
  • is there a defined activation order that may be important? 是否有定义的激活顺序可能很重要?
  • is the order important, if activated manually over CLI ( -Pprofile1,profile2 )? 如果通过CLI手动激活( -Pprofile1,profile2 ),那么重要的顺序是什么?

Thank you 谢谢

There is no resolving conflicts happening - only overriding. 没有解决冲突发生 - 只有覆盖。 Afaik the order is settings, pom, and then command line. Afaik顺序是设置,pom,然后命令行。 For multiple profiles in a pom and settings file the order in the file matters as well and beyond that things are different depending on Maven version. 对于pom和设置文件中的多个配置文件,文件中的顺序也很重要,除此之外根据Maven版本的不同而不同。

I would strongly suggest to reduce your usage of profiles so that you do NOT have to worry about these complexities and certainly get the help plugin installed. 我强烈建议减少您对配置文件的使用,这样您就不必担心这些复杂性,并且肯定会安装帮助插件。

Also you can see the effective pom within Eclipse in the M2Eclipse plugin in the POM editor. 您还可以在POM编辑器中的M2Eclipse插件中看到Eclipse中的有效pom。 That should help you in the mean time. 那应该会帮助你。

And answer to your questions: 并回答你的问题:

Yes

Yes

Yes

All orders matter and can result in, lets just say "surprising" results sometimes. 所有订单都很重要并且可能导致,有时候只会说“令人惊讶”的结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检测激活的maven配置文件? - How to detect what maven profiles are activated? 通过在命令行上指定多个Maven配置文件来堆叠属性 - Stacking properties by specifying multiple Maven profiles on the command line 自定义 spring 引导配置文件未在 IntelliJ 中激活 - Custom spring boot profiles not getting activated in IntelliJ 如何使用Heroku管理多个Spring配置文件 - How to manage multiple Spring profiles with Heroku 如何在Spring中为多个配置文件设置默认实现? - How to set default implementation for multiple profiles in Spring? Spring Boot Pom-如何从聚合Pom继承配置文件和属性? - Spring Boot pom - how to inherit profiles and properties from aggregator pom? 多个Maven配置文件激活多个Spring配置文件 - Multiple Maven profiles activate multiple Spring profiles 如何排除默认的application.properties在Spring启动项目的Maven中使用配置文件添加自定义属性文件? - How to exclude default application.properties add custom properties file using profiles in maven for spring boot project? Maven 配置文件 - 如何获取分配给.properties 文件中的属性的值并将它们分配给我的 class 中的变量? - Maven Profiles - How do i get the values assigned to properties in the .properties file and assign them to variables in my class? 如何将 application.properties 与 application-default.properties 合并并包含在 Spring Boot >2.4 的其他测试配置文件中 - How to merge application.properties with application-default.properties and include in other test profiles with Spring Boot >2.4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM