SpringBoot整合Spring Cloud Alibaba

本文介绍如何使用SpringBoot整合SpringCloud及SpringCloud Alibaba,包括整合步骤、依赖配置及验证方法等内容。

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

Spring Cloud Alibaba学习笔记》其实是阿里的微服务解决方案,是阿里巴巴结合自身微服务实践,开源的微服务全家桶,在Spring Cloud项目中孵化成为Spring Cloud的子项目。第一代的Spring Cloud标准中很多组件已经停更,如:Eureak,zuul等。所以Spring Cloud Alibaba很有可能成为Spring Cloud第二代的标准实现,所以许多组件在业界逐渐开始使用,已有很多成功案例。值得一提的是Spring Cloud Alibaba对Dubbo做了很好的兼容,同时也提供了一些强大的功能,如 Sentinel 流控 ,Seata 分布式事务,Nacos 服务发现与注册等等。 但现在网上学习SpringCloudAlibab的资料要么不全要么很少,完整的就更别说了,所以今天给大家免费分享的正是Alibaba出品的Spring Cloud Alibaba 的学习文档,图文并茂,量身打造,非常适合再学习Spring Cloud Alibaba的朋友观看!下面来看看这份Spring Cloud Alibaba 学习文档吧. Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。 为什么使用Spring Boot?很简单,我仅仅只需要非常少的几个配置就可以迅速方便的搭建起来一套 Web 项目或者是构建一个微服务! 本文档主要介绍了Spring Boot 框架快速入门教程以大量示例讲解了 Spring Boot 在各类情境中的应用,让读者可以跟着笔者的思维和代码快速理解并掌握。感兴趣的可以了解一下
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值