我的父级 pom.xml
中有 2 个配置文件(用于生产和开发)。所以我想在我的子模块中继承这个配置文件...我怎样才能实现这一点?我如何继承 parent 的个人资料?或者我需要在子模块中指定具有相同 ID 的配置文件,一切都可以吗?
最佳答案
您需要将以下内容添加到子 pom.xml 文件中以从父级继承,这意味着继承您在父级中定义的所有配置文件:
<project ..>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>TheGroupIdYourParentHas</groupId>
<artifactId>TheArtifactIdYourParentHas</artifactId>
<version>1.0.0</version>
</parent>
...
</project>
顺便说一句。您应该考虑使用 distinguishing between production and development 的配置文件。通常你应该简单地调用
mvn package
生成适合生产的正确包,无需使用任何配置文件。我写了一个blog article to handle such things in a better way .
关于java - 梅文。如何从paren pom.xml继承配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14039292/