Maven 子模块未从父pom继承配置文件
我有一个父母和孩子。父级定义了一些配置文件:Maven 子模块未从父pom继承配置文件,maven,multi-module,Maven,Multi Module,我有一个父母和孩子。父级定义了一些配置文件: <profiles> <profile> <id>local</id> <properties> <build.profile.id>local</build.profile.id> </properties> </profile> </profile
<profiles>
<profile>
<id>local</id>
<properties>
<build.profile.id>local</build.profile.id>
</properties>
</profile>
</profiles>
因此,我猜只有属性似乎是以某种方式被继承的。正如您已经发现的,在POM继承期间,具有相同
的两个配置文件不会合并。但是,作为一种解决方法,您可以使用两个不同的
配置文件,但使用相同的配置文件:
本地家长
地方的
地方的
及
本地儿童
地方的
服务A
使用
-Dlocal
而不是-p local
运行构建现在激活了两个配置文件,它们共同具有所需的效果。我喜欢您的解决方案。我还注意到,属性是从父pom继承的,也就是说,如果我在父pom中的配置文件下定义了一个属性,那么在调用子pom时,该属性的值也是作为“全局”属性继承的。看看我的编辑2。
<profiles>
<profile>
<id>local</id>
<properties>
<name>serviceA</name>
</properties>
</profile>
</profiles>
...
<properties>
<build.profile.id>local</build.profile.id>
<name>serviceA</name>
</properties>
<profiles>
<profile>
<id>local</id>
<properties>
<name>serviceA</name>
</properties>
</profile>
</profiles>
<profiles>
<profile>
<id>local-parent</id>
<activation>
<property>
<name>local</name>
</property>
</activation>
<properties>
<build.profile.id>local</build.profile.id>
</properties>
</profile>
</profiles>
<profiles>
<profile>
<id>local-child</id>
<activation>
<property>
<name>local</name>
</property>
</activation>
<properties>
<name>serviceA</name>
</properties>
</profile>
</profiles>