SpringBoot整合Spring Cloud Alibaba
spring-cloud官方中文文档
spring-cloud官方文档
Spring Cloud Alibaba官方文档
文章目录
1. SpringBoot整合Spring Cloud
<dependencyManagement> <!--SpringBoot整合Spring Cloud--> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.SR1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
2. SpringBoot整合Spring Cloud Alibaba
<dependencyManagement> <!--SpringBoot整合Spring Cloud--> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.SR1</version> <type>pom</type> <scope>import</scope> </dependency> <!--SpringBoot整合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> </dependencies> </dependencyManagement>
3. 为什么SpringBoot整合Spring Cloud ?
原因:如果想用Spring Cloud中的技术,需要指定版本,而Spring Cloud对子项目指定了版本,并做好了整合。
4. 为什么SpringBoot 整合Spring Cloud Alibaba?
原因:如果想用Spring Cloud Alibaba中的技术,需要指定版本,而Spring Cloud Alibaba都对子项目指定了版本,并做好了整合。
5. 为什么SpringBoot 整合SC和SCA分前后?
SpringBoot 整合Spring Cloud Alibaba要先整合Spring Cloud,因为Spring Cloud Alibaba属于Spring Cloud的子项目,在Spring Cloud中对Spring Cloud Alibaba子项目指定了版本,并做了整合。
6. 整合案例
-
例: SpringBoot整合Spring Cloud Alibaba中的nacos,只需下面这样写即可,不需要指定版本号。 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
7. 整合完成后,验证整合是否正确?
执行maven构建,如果构建成功,则说明整合成功
mvn clean install
8. 整合归纳
1. 整合周边技术,判断该技术是否是单独的技术 2. 单独存在的技术可以直接整合 3. 像SpringCloud子项目这种的技术,先整合所属技术组,再整合所属技术组下面的技术。