【Spring Boot】Spring Boot之兩種引入spring boot maven依賴的方式


一、方式一:spring-boot-starter-parent

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

 進入spring-boot-starter-parent里,可以發現它其實依賴了我們下面要講的spring-boot-dependencies模塊 。

二、方式二:使用spring-boot-dependencies

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.2.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

使用這種方式就不用繼承父模塊,可以解決單繼承的問題。這樣就可以繼承其他父模塊,比如自己創建的父模塊。
scope=import,type=pom表示在此pom中引入spring-boot-dependencies的pom的所有內容,注意只能在dependencyManagement中使用。
大多數我們可能用到的包依賴和插件依賴都已經在spring-boot-dependencies中定義好了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM