<b id="wionh"></b>

<u id="wionh"><address id="wionh"><meter id="wionh"></meter></address></u>

maven中的parent標簽

時間:2022-11-09 09:30:06 類型:JAVA
字號:    

簡介(what)

parent標簽類似java中的繼承,復用依賴,減少冗余配置


使用場景(when)

在多模塊(module)的項目中,有很多模塊中的pom中存在相同的引用,如果此時聲明一個父pom文件,將公用的依賴提取到父pom文件中(即使用標簽),將大大減少其他pom文件中的依賴的配置

如何使用(how):

假如我們有一個項目中有2個module

我們可以這樣使用:

  1. 創建一個新的module,名為parent(當然也可以叫其他名字),存放父pom,父pom中,也可以使用parent標簽(一般放 大部分module都使用的組件,如spirng boot)

    在其他兩個module中使用parent標簽,其坐標就是父pom中聲明的坐標

    step 1:創建一個新的module,名為parent,存放父pom

<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.2.0</version>
<packaging>pom</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.2.RELEASE</version>
    <relativePath/>
</parent>

step 2:在其他兩個module中使用parent標簽

module1中:

<parent>
    <groupId>com.example</groupId>
    <artifactId>parent</artifactId>
    <version>1.2.0</version>
</parent>

module2中

<parent>
    <groupId>com.example</groupId>
    <artifactId>parent</artifactId>
    <version>1.2.0</version>
    <relativePath>./parent/</relativePath>
</parent>


中文无码妇乱子二区三区_久久亚洲精品无码福利播放_毛片一级_日韩aⅴ无码久久精品免费

<b id="wionh"></b>

<u id="wionh"><address id="wionh"><meter id="wionh"></meter></address></u>

<