項目不繼承springboot的parent

      通常我們在創建springboot項目時,會指定parent爲springboot的parent項目,類似這樣

      

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

 

   但是有的時候,在公司內部,封裝了自己的parent項目,這個時候就不能再繼承springboot的parent項目了,這個時候我們如果還想使用springboot parent項目中的dependencyManagement中指定的版本號的好處要怎麼辦呢,這種問題的解決辦法就是在dependencyManagement中引入spring-boot-dependencies就可以,類似下面這樣.

 

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

 

  這樣,在子類中就可以不用指定版本號了,利用了springboot幫我們依賴管理的功能,同時還能引用我們公司自己的parent項目.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章