springboot項目中如何在pom文件覆蓋starter中默認指定的jar版本號


分兩種情況:

1.項目繼承自spring-boot-starter-parent 

    通過定義properties的方式改變starter中的默認版本

<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>

<properties>
<spring-data-releasetrain.version>Fowler-SR2</spring-data-releasetrain.version>
</properties>

   

 2.不繼承spring-boot-starter-parent 

   在引入spring-boot-dependencies之前指定要覆蓋的依賴,但要注意 type 和 scope屬性

<dependencyManagement>
 <dependencies>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-releasetrain</artifactId>
    <version>Fowler-SR2</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
  <dependency>     <!-- Import dependency management from Spring Boot -->     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-dependencies</artifactId>     <version>2.1.2.RELEASE</version>     <type>pom</type>     <scope>import</scope>   </dependency> </dependencies> </dependencyManagement>

 


免責聲明!

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



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