From 038a6be4e645948aecf49077b7523060dfeb2e6a Mon Sep 17 00:00:00 2001
From: YunaiV <>
Date: Fri, 14 Feb 2020 00:03:52 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20spring=20cloud=20alibaba?=
=?UTF-8?q?=20sentinel=20=E6=9C=8D=E5=8A=A1=E5=AE=B9=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 29 +++++++++++++++----
.../pom.xml | 14 ++-------
.../provider/DemoProviderApplication.java | 1 -
.../provider/web/GlobalExceptionHandler.java | 8 +++--
4 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index 4ca96048..2eae0a3d 100644
--- a/README.md
+++ b/README.md
@@ -122,18 +122,21 @@
# Spring Cloud Alibaba 专栏
+## Spring Cloud Alibaba 全家桶
+
* [《芋道 Spring Cloud Alibaba 注册中心 Nacos 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Nacos-Discovery/?github) 对应 [labx-01](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-01)
-* [《芋道 Spring Cloud Netflix 负载均衡 Ribbon 入门》](http://www.iocoder.cn/Spring-Cloud-Netflix/Ribbon/?github) 对应 [labx-02](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-02)
-* [《芋道 Spring Cloud 声明式调用 Feign 入门》](http://www.iocoder.cn/Spring-Cloud/Feign/?github) 对应 [labx-03](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-03)
* 《芋道 Spring Cloud Alibaba 服务调用 Dubbo 入门》
* [《芋道 Spring Cloud Alibaba 服务容错 Sentinel 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Sentinel/?github) 对应 [labx-04](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-04)
-* 《芋道 Spring Cloud Netflix 服务容错 Hystrix 入门》
* 《芋道 Spring Cloud Alibaba 消息队列 RocketMQ 入门》
* 《芋道 Spring Cloud Alibaba 配置中心 Nacos 入门》
+
+## 推荐搭配食用
+
+* [《芋道 Spring Cloud Netflix 负载均衡 Ribbon 入门》](http://www.iocoder.cn/Spring-Cloud-Netflix/Ribbon/?github) 对应 [labx-02](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-02)
+* [《芋道 Spring Cloud 声明式调用 Feign 入门》](http://www.iocoder.cn/Spring-Cloud/Feign/?github) 对应 [labx-03](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-03)
* 《芋道 Spring Cloud 服务网关 Spring Cloud Gateway 入门》
-* 《芋道 Spring Cloud Netflix 服务网关 Zuul 入门》
-* 《芋道 Spring Cloud 链路追踪 Sleuth 入门》
* 《芋道 Spring Cloud 链路追踪 SkyWalking 入门》
+
* TODO 监控
# Spring Cloud 专栏
@@ -151,6 +154,22 @@
## 服务容错
* [《芋道 Spring Cloud Alibaba 服务容错 Sentinel 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Sentinel/?github) 对应 [labx-04](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-04)
+* 《芋道 Spring Cloud Netflix 服务容错 Hystrix 入门》
+
+## API 网关
+
+* 《芋道 Spring Cloud 服务网关 Spring Cloud Gateway 入门》
+* 《芋道 Spring Cloud Netflix 服务网关 Zuul 入门》
+
+## 配置中心
+
+* 《芋道 Spring Cloud Alibaba 配置中心 Nacos 入门》
+* 《芋道 Spring Cloud 配置中心 Apollo 入门》
+
+## 链路追踪
+
+* 《芋道 Spring Cloud 链路追踪 Sleuth 入门》
+* 《芋道 Spring Cloud 链路追踪 SkyWalking 入门》
---------
diff --git a/labx-04/labx-04-sca-sentinel-demo01-provider/pom.xml b/labx-04/labx-04-sca-sentinel-demo01-provider/pom.xml
index 2b0a0904..83996125 100644
--- a/labx-04/labx-04-sca-sentinel-demo01-provider/pom.xml
+++ b/labx-04/labx-04-sca-sentinel-demo01-provider/pom.xml
@@ -10,20 +10,10 @@
4.0.0
labx-04-sca-sentinel-demo01-provider
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 6
- 6
-
-
-
-
+ 1.8
+ 1.8
2.2.4.RELEASE
Hoxton.SR1
2.2.0.RELEASE
diff --git a/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/DemoProviderApplication.java b/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/DemoProviderApplication.java
index c11a5647..569f4d28 100644
--- a/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/DemoProviderApplication.java
+++ b/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/DemoProviderApplication.java
@@ -4,7 +4,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
-//@EnableWebMvc
public class DemoProviderApplication {
public static void main(String[] args) {
diff --git a/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/web/GlobalExceptionHandler.java b/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/web/GlobalExceptionHandler.java
index a02f3017..f60b2fe6 100644
--- a/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/web/GlobalExceptionHandler.java
+++ b/labx-04/labx-04-sca-sentinel-demo01-provider/src/main/java/cn/iocoder/springcloudalibaba/labx04/sentineldemo/provider/web/GlobalExceptionHandler.java
@@ -1,6 +1,7 @@
package cn.iocoder.springcloudalibaba.labx04.sentineldemo.provider.web;
import com.alibaba.csp.sentinel.slots.block.BlockException;
+import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -11,9 +12,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class GlobalExceptionHandler {
@ResponseBody
- @ExceptionHandler(value = BlockException.class)
- public String blockExceptionHandler(BlockException blockException) {
- return "请求被拦截,拦截类型为 " + blockException.getClass().getSimpleName();
+ @ExceptionHandler(value = BlockException.class) // 因为这里是示例,所以暂时使用 JSONObject,实际项目最终定义一个 CommonResult。
+ public JSONObject blockExceptionHandler(BlockException blockException) {
+ return new JSONObject().fluentPut("code", 1024)
+ .fluentPut("msg", "请求被拦截,拦截类型为 " + blockException.getClass().getSimpleName());
}
}