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,这就是**“扇出”**,在 扇出链路中出现调用某个微服务的响应时间过长或不可用时,调用它的微服务会占用越来越多的系统资源,进一步导致系统崩溃。当一个模块的实例失败后,还会继续接收流量,然后这个有问题的模块继续调用别的模块,导致发生了级联故障,这就叫做雪崩。
解决方案
服务熔断和服务降级就可以视为解决服务雪崩的手段之一。