天天看點

一起來學SpringCloud Maven版本控制

序言

​ 在學習Sping Cloud之前應該先知道其與Spring Boot的對應版本,不然會出現各種不相容的情況,和一些未知的問題。

怎麼檢視版本呢?

通路網站

https://start.spring.io/actuator/info
           

然後呢找到

spring-cloud

這個節點

{
    "Finchley.M2": "Spring Boot >=2.0.0.M3 and <2.0.0.M5",
    "Finchley.M3": "Spring Boot >=2.0.0.M5 and <=2.0.0.M5",
    "Finchley.M4": "Spring Boot >=2.0.0.M6 and <=2.0.0.M6",
    "Finchley.M5": "Spring Boot >=2.0.0.M7 and <=2.0.0.M7",
    "Finchley.M6": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1",
    "Finchley.M7": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2",
    "Finchley.M9": "Spring Boot >=2.0.0.RELEASE and <=2.0.0.RELEASE",
    "Finchley.RC1": "Spring Boot >=2.0.1.RELEASE and <2.0.2.RELEASE",
    "Finchley.RC2": "Spring Boot >=2.0.2.RELEASE and <2.0.3.RELEASE",
    "Finchley.SR4": "Spring Boot >=2.0.3.RELEASE and <2.0.999.BUILD-SNAPSHOT",
    "Finchley.BUILD-SNAPSHOT": "Spring Boot >=2.0.999.BUILD-SNAPSHOT and <2.1.0.M3",
    "Greenwich.M1": "Spring Boot >=2.1.0.M3 and <2.1.0.RELEASE",
    "Greenwich.SR3": "Spring Boot >=2.1.0.RELEASE and <2.1.10.BUILD-SNAPSHOT",
    "Greenwich.BUILD-SNAPSHOT": "Spring Boot >=2.1.10.BUILD-SNAPSHOT and <2.2.0.M4",
    "Hoxton.RC1": "Spring Boot >=2.2.0.M4 and <2.2.1.BUILD-SNAPSHOT",
    "Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.2.1.BUILD-SNAPSHOT"
}
           

大概就是這個樣子 比如

Greenwich.SR3

這個版本 一般對應着

Spring Boot >=2.1.0.RELEASE and <2.1.10.BUILD-SNAPSHOT

也就是Spring Boot 版本大于2.1.0 小于2.1.10。

然後來官方提供了管理Spring Cloud 個個版本相容的pom,就是下面這個

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
 </dependencyManagement>
           

然後就可以像Spring Boot父工程那樣管理自己内部的相容版本号啦!

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