简体   繁体   English

Maven的。 如何从paren pom.xml继承配置文件?

[英]Maven. How to inherit profile from paren pom.xml?

I have 2 profiles in my parent pom.xml (for production and for development). 我的父pom.xml有2个配置文件(用于生产和开发)。 So I want to inherit this profiles in my child modules... How I can achieve this? 因此,我想在子模块中继承此配置文件...如何实现此目的? How I can inherit parent's profile? 如何继承父母的资料? Or I need to specify profile with same ID in child module and all be ok? 还是我需要在子模块中指定具有相同ID的配置文件,一切都可以吗?

You need to give the following into your child pom.xml file to inherit from your parent which implies to inherit all profiles you have defined in your parent: 您需要将以下内容放入子pom.xml文件以从父级继承,这意味着继承您在父级中定义的所有配置文件:

   <project ..>
      <modelVersion>4.0.0</modelVersion>

      <parent>
        <groupId>TheGroupIdYourParentHas</groupId>
        <artifactId>TheArtifactIdYourParentHas</artifactId>
        <version>1.0.0</version>
      </parent>
      ...
   </project>

BTW. BTW。 You should think about using profiles for distinguishing between production and development . 您应该考虑使用概要文件来区分生产和开发 Usually you should simply call 通常你应该简单地打电话

mvn package

to produce the right package which is for production without using of any profile. 无需使用任何配置文件即可生产出适合生产的正确包装。 I wrote an blog article to handle such things in a better way . 我写了一篇博客文章,以更好地处理此类问题

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM