Spring Cloud Alibaba從孵化器版本畢業:https://github.com/alibaba/spring-cloud-alibaba,記錄一下自己學習Spring Cloud Alibaba的筆記。
1.在整合Spring Cloud Alibaba之前,首先需要整合Spring Cloud
在Spring Cloud的官網可以了解到目前最新的穩定版Spring Cloud版本,我所選擇版本是Greenwich.SR3。在項目的pom.xml文件中加入以下代碼段就可以整合Spring Cloud了。
<dependencyManagement> <dependencies> <!-- 整合spring-cloud--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.SR3</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
2.接下來整合Spring CLoud Alibaba
整合Spring CLoud Alibaba需要注意與Spring Cloud之間的版本對應,以下是官網給出的版本對應關系。
Spring Cloud Version | Spring Cloud Alibaba Version | Spring Boot Version |
---|---|---|
Spring Cloud Greenwich |
2.1.0.RELEASE |
2.1.X.RELEASE |
Spring Cloud Finchley |
2.0.0.RELEASE |
2.0.X.RELEASE |
Spring Cloud Edgware |
1.5.0.RELEASE |
1.5.X.RELEASE |
對於我所使用的 Spring Cloud Greenwich.SR3版本,只需要在 dependencyManagement 中添加如下內容:
<!-- 整合spring-cloud-alibaba--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2.1.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>
如果你使用 Spring Cloud Finchley 版本,請在 dependencyManagement 中添加如下內容:
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2.0.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>
如果你使用 Spring Cloud Edgware 版本,請在 dependencyManagement 中添加如下內容:
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>1.5.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>
整合完畢。