spring-cloud官方中文文档https://www.springcloud.cc/spring-cloud-dalston.html
spring-cloud官方文档https://cloud.spring.io/spring-cloud-static/Greenwich.SR1/single/spring-cloud.html#_quick_start_6
Spring Cloud Alibaba官方文档https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E

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子项目这种的技术,先整合所属技术组,再整合所属技术组下面的技术。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐