微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SpringCloud介绍

SpringCloud

1、官网

springcloud官网:https://spring.io/projects/spring-cloud

Springcloud和Springboot之间的依赖关系:https://spring.io/projects/spring-cloud#overview

更详细的版本对应查看方法https://start.spring.io/actuator/info
解析查看json串返回结果

2、IDEA中实现热部署

1、pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork>
                <addResources>true</addResources>
            </configuration>
        </plugin>
    </plugins>
</build>

2、application.yml

spring:
  devtools:
    restart:
      enabled: true
  freemarker:
    cache: false

3、IDEA中配置

  • File-Settings-Compiler-Build Project automatically
  • ctrl + shift + alt + / ,选择Registry,勾上 Compiler automake allow when app running

3、开启IDEA中的run DashBoard

修改idea的workspace.xml文件添加以下内容

  <component name="RunDashboard">
    <option name="configurationTypes">
      <set>
        <option value="SpringBootApplicationConfigurationType" />
      </set>
    </option>
  </component> 

4、常见的微服务替代方案

https://spring.io/blog/2018/12/12/spring-cloud-greenwich-rc1-available-Now

5、各种微服务组件

在这里插入图片描述

  • 服务注册中心:Eureka、Zookeeper、Consul、Nacos
  • 服务调用:Ribbon(负载均衡)、LoadBalancer、Feign、OpenFeign
  • 服务降级:Hystrix、resilience4j、alibaba Sentinel
  • 服务网关:Zuul、gateway
  • 服务配置:Config、Nacos、Apollo
  • 服务总线:Bus、Nacos

6、服务雪崩与解决方

什么是服务雪崩?

当多个微服务互相调用的时候,微服务A调用微服务B,B调C,C调D,这就是**“扇出”**,在 扇出链路中出现调用某个微服务的响应时间过长或不可用时,调用它的微服务会占用越来越多的系统资源,进一步导致系统崩溃。当一个模块的实例失败后,还会继续接收流量,然后这个有问题的模块继续调用别的模块,导致发生了级联故障,这就叫做雪崩。

解决方

服务熔断和服务降级就可以视为解决服务雪崩的手段之一。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐