spring-boot-starter-parent和spring-boot-dependencies


如何創建一個SpringBoot項目,SpringBoot的依賴引入都是基於starter的,通常創建一個SpringBoot項目都是通過繼承關系指定pom文件中的parent

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

然后使用<dependency></dependency>標簽來引入相應的依賴,比如常用的lombok

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>

除了繼承spring-boot-starter-parent的方式外,還有一種方式那就是通過<dependency/>引入spring-boot-dependencies相關依賴。

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

在使用maven創建SpringCloud聚合項目時,通常在父pom文件中通過spring-boot-dependencies引入SpringBoot相關依賴,然后子項目使用parent標簽來繼承父項目,方便依賴管理。


免責聲明!

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



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