【springboot】maven依賴實現的兩種方式

繼承spring-boot-starter-parent項目

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

導入spring-boot-dependencies項目依賴

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

 注意:

1.版本更改(注意所及更改版本可能會導致不兼容)

繼承方式:只需以下方式即可

<properties>
   <slf4j.version>1.7.25<slf4j.version>
</properties>

導入方式:把要升級的組件依賴放到Spring Boot依賴之前

<dependencyManagement>
   <dependencies>
       <!-- Override Spring Data release train provided by Spring Boot -->
       <dependency>
           <groupId>org.springframework.data</groupId>
           <artifactId>spring-data-releasetrain</artifactId>
           <version>Fowler-SR2</version>
           <scope>import</scope>
           <type>pom</type>
       </dependency>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-dependencies</artifactId>
           <version>2.1.3.RELEASE</version>
           <type>pom</type>
           <scope>import</scope>
       </dependency>
   </dependencies>
</dependencyManagement>

 

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