From cb85acd6b8d9d9422a1f8de6213b6cdd963dbffe Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Wed, 4 Mar 2020 10:19:34 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E4=B8=8A=E4=BC=A0.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..c3b9776 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,7 @@ +# Default ignored files +/workspace.xml + +/misc.xml +/modules.xml +/SpringCloudLearning.iml +/vcs.xml -- Gitee From 57b491949150a5403c3d92a40d4b11b349e84803 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Wed, 4 Mar 2020 10:55:35 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ribbon=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 4 ++++ springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/.idea/.gitignore b/.idea/.gitignore index c3b9776..5ecbb78 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -5,3 +5,7 @@ /modules.xml /SpringCloudLearning.iml /vcs.xml +/libraries/ +/.name +/encodings.xml +/compiler.xml diff --git a/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml b/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml index 70fe5b0..f48328a 100644 --- a/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml +++ b/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml @@ -42,6 +42,7 @@ org.springframework.cloud spring-cloud-starter-ribbon + 1.4.7.RELEASE -- Gitee From fd61da7e153d50dcf15ac8b7ed985c421d704b9d Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Thu, 5 Mar 2020 23:21:28 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E4=BD=BF=E7=94=A8spring-cloud-starter-ne?= =?UTF-8?q?tflix-ribbon=EF=BC=8C=E6=9B=BF=E4=BB=A3spring-cloud-starter-rib?= =?UTF-8?q?bon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- springcloud-alibaba/nacos-config/nacos-consumer/pom.xml | 2 +- springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/springcloud-alibaba/nacos-config/nacos-consumer/pom.xml b/springcloud-alibaba/nacos-config/nacos-consumer/pom.xml index 70fe5b0..a98eed9 100644 --- a/springcloud-alibaba/nacos-config/nacos-consumer/pom.xml +++ b/springcloud-alibaba/nacos-config/nacos-consumer/pom.xml @@ -41,7 +41,7 @@ org.springframework.cloud - spring-cloud-starter-ribbon + spring-cloud-starter-netflix-ribbon diff --git a/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml b/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml index f48328a..a98eed9 100644 --- a/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml +++ b/springcloud-alibaba/nacos-discovery/nacos-consumer/pom.xml @@ -41,8 +41,7 @@ org.springframework.cloud - spring-cloud-starter-ribbon - 1.4.7.RELEASE + spring-cloud-starter-netflix-ribbon -- Gitee From 0b688e0328005ac0b51509226f9f076cdd34c339 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Fri, 6 Mar 2020 01:30:47 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E4=BD=BF=E7=94=A8spring-cloud-starter-ne?= =?UTF-8?q?tflix-ribbon=EF=BC=8C=E6=9B=BF=E4=BB=A3spring-cloud-starter-rib?= =?UTF-8?q?bon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nacos-discovery-sentinel/nacos-consumer/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/springcloud-alibaba/nacos-discovery-sentinel/nacos-consumer/pom.xml b/springcloud-alibaba/nacos-discovery-sentinel/nacos-consumer/pom.xml index 523952d..e6347c0 100644 --- a/springcloud-alibaba/nacos-discovery-sentinel/nacos-consumer/pom.xml +++ b/springcloud-alibaba/nacos-discovery-sentinel/nacos-consumer/pom.xml @@ -41,7 +41,7 @@ org.springframework.cloud - spring-cloud-starter-ribbon + spring-cloud-starter-netflix-ribbon -- Gitee From ba8a6280c3e6e35f8019205848da4ce3359729ff Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sat, 7 Mar 2020 08:57:50 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9spring-cloud-config?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config-server/src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chapter6/config-server/src/main/resources/application.properties b/chapter6/config-server/src/main/resources/application.properties index 21a8768..99273e5 100755 --- a/chapter6/config-server/src/main/resources/application.properties +++ b/chapter6/config-server/src/main/resources/application.properties @@ -2,9 +2,9 @@ spring.application.name=config-server server.port=8888 -spring.cloud.config.server.git.uri=https://github.com/forezp/SpringcloudConfig/ +spring.cloud.config.server.git.uri=https://gitee.com/yanghaojie002/SpringcloudConfig/ spring.cloud.config.server.git.searchPaths=respo spring.cloud.config.label=master -spring.cloud.config.server.git.username= -spring.cloud.config.server.git.password= +spring.cloud.config.server.git.username=13486032976@163.com +spring.cloud.config.server.git.password=qsx741olm1598753 -- Gitee From 1acf015f52bae6fb89660e33cdd94f7a77e4254e Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sat, 7 Mar 2020 09:01:01 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9spring-cloud-config?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config-server/src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter6/config-server/src/main/resources/application.properties b/chapter6/config-server/src/main/resources/application.properties index 99273e5..1821cf1 100755 --- a/chapter6/config-server/src/main/resources/application.properties +++ b/chapter6/config-server/src/main/resources/application.properties @@ -5,6 +5,6 @@ server.port=8888 spring.cloud.config.server.git.uri=https://gitee.com/yanghaojie002/SpringcloudConfig/ spring.cloud.config.server.git.searchPaths=respo spring.cloud.config.label=master -spring.cloud.config.server.git.username=13486032976@163.com -spring.cloud.config.server.git.password=qsx741olm1598753 +spring.cloud.config.server.git.username= +spring.cloud.config.server.git.password= -- Gitee From 310eb76bc702e71be40938acfa1a592ed0582b88 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sat, 7 Mar 2020 12:05:20 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config-server/src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chapter8/config-server/src/main/resources/application.properties b/chapter8/config-server/src/main/resources/application.properties index e3baefd..2fbcfb8 100755 --- a/chapter8/config-server/src/main/resources/application.properties +++ b/chapter8/config-server/src/main/resources/application.properties @@ -2,10 +2,10 @@ spring.application.name=config-server server.port=8888 -spring.cloud.config.server.git.uri=https://github.com/forezp/SpringcloudConfig/ +spring.cloud.config.server.git.uri=https://gitee.com/yanghaojie002/SpringcloudConfig/ spring.cloud.config.server.git.searchPaths=respo spring.cloud.config.label=master -spring.cloud.config.server.git.username=your username -spring.cloud.config.server.git.password=your password +spring.cloud.config.server.git.username= +spring.cloud.config.server.git.password= eureka.client.serviceUrl.defaultZone=http://localhost:8889/eureka/ \ No newline at end of file -- Gitee From 2420118dce546945b94c0467604739f66ffb3d2d Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sat, 7 Mar 2020 14:41:40 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eureka-server/src/main/resources/application-peer1.yml | 4 ++-- .../eureka-server/src/main/resources/application-peer2.yml | 4 ++-- chapter10/eureka-server/src/main/resources/application.yml | 3 +++ chapter10/service-hi/src/main/resources/bootstrap.yml | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 chapter10/eureka-server/src/main/resources/application.yml diff --git a/chapter10/eureka-server/src/main/resources/application-peer1.yml b/chapter10/eureka-server/src/main/resources/application-peer1.yml index 58394c6..614da65 100755 --- a/chapter10/eureka-server/src/main/resources/application-peer1.yml +++ b/chapter10/eureka-server/src/main/resources/application-peer1.yml @@ -1,8 +1,8 @@ server: port: 8761 -spring: - profiles: peer1 +#spring: +# profiles: peer1 eureka: instance: hostname: peer1 diff --git a/chapter10/eureka-server/src/main/resources/application-peer2.yml b/chapter10/eureka-server/src/main/resources/application-peer2.yml index bc1c565..cf16424 100755 --- a/chapter10/eureka-server/src/main/resources/application-peer2.yml +++ b/chapter10/eureka-server/src/main/resources/application-peer2.yml @@ -2,8 +2,8 @@ server: port: 8769 -spring: - profiles: peer2 +#spring: +# profiles: peer2 eureka: instance: hostname: peer2 diff --git a/chapter10/eureka-server/src/main/resources/application.yml b/chapter10/eureka-server/src/main/resources/application.yml new file mode 100644 index 0000000..e887b19 --- /dev/null +++ b/chapter10/eureka-server/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: peer1 \ No newline at end of file diff --git a/chapter10/service-hi/src/main/resources/bootstrap.yml b/chapter10/service-hi/src/main/resources/bootstrap.yml index 1128082..8a35803 100755 --- a/chapter10/service-hi/src/main/resources/bootstrap.yml +++ b/chapter10/service-hi/src/main/resources/bootstrap.yml @@ -1,7 +1,7 @@ eureka: client: serviceUrl: - defaultZone: http://peer2:8769/eureka/,http://peer1:8761/eureka/ + defaultZone: http://peer1:8761/eureka/,http://peer2:8769/eureka/ server: port: 8762 spring: -- Gitee From f182b18c969e0dacf89b579803be7e87d64ffbe2 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sat, 7 Mar 2020 17:48:41 +0800 Subject: [PATCH 09/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9DockerFile=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chapter11/eureka-server/src/main/docker/Dockerfile | 2 +- chapter11/service-hi/src/main/docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter11/eureka-server/src/main/docker/Dockerfile b/chapter11/eureka-server/src/main/docker/Dockerfile index 687de4d..416b4f7 100755 --- a/chapter11/eureka-server/src/main/docker/Dockerfile +++ b/chapter11/eureka-server/src/main/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM frolvlad/alpine-oraclejdk8:slim +FROM openjdk:8u242-slim VOLUME /tmp ADD eureka-server-0.0.1-SNAPSHOT.jar app.jar #RUN bash -c 'touch /app.jar' diff --git a/chapter11/service-hi/src/main/docker/Dockerfile b/chapter11/service-hi/src/main/docker/Dockerfile index 92fbb35..ef8076f 100755 --- a/chapter11/service-hi/src/main/docker/Dockerfile +++ b/chapter11/service-hi/src/main/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM frolvlad/alpine-oraclejdk8:slim +FROM openjdk:8u242-slim VOLUME /tmp ADD service-hi-0.0.1-SNAPSHOT.jar app.jar #RUN bash -c 'touch /app.jar' -- Gitee From 3ac75484eb657d176037f3c536020edbf6cd8955 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sat, 7 Mar 2020 23:52:22 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sc-f-gateway-first-sight/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 sc-f-gateway-first-sight/.gitignore diff --git a/sc-f-gateway-first-sight/.gitignore b/sc-f-gateway-first-sight/.gitignore new file mode 100644 index 0000000..797b705 --- /dev/null +++ b/sc-f-gateway-first-sight/.gitignore @@ -0,0 +1 @@ +*.iml \ No newline at end of file -- Gitee From b86c336cd43c4e4eeadf3dd51a0bfe652b775a70 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sun, 8 Mar 2020 08:16:21 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sc-f-gateway-predicate/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sc-f-gateway-predicate/.gitignore diff --git a/sc-f-gateway-predicate/.gitignore b/sc-f-gateway-predicate/.gitignore new file mode 100644 index 0000000..dc48b22 --- /dev/null +++ b/sc-f-gateway-predicate/.gitignore @@ -0,0 +1,2 @@ +*.iml +target \ No newline at end of file -- Gitee From 213476ab22f803ecfb7ddcd80ae2e3c1ae66e7f0 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sun, 8 Mar 2020 09:11:02 +0800 Subject: [PATCH 12/23] 'update' --- .../target/classes/application.yml | 84 ------------------ .../target/classes/gateway/Application.class | Bin 736 -> 0 bytes 2 files changed, 84 deletions(-) delete mode 100644 sc-f-gateway-predicate/target/classes/application.yml delete mode 100644 sc-f-gateway-predicate/target/classes/gateway/Application.class diff --git a/sc-f-gateway-predicate/target/classes/application.yml b/sc-f-gateway-predicate/target/classes/application.yml deleted file mode 100644 index 99fd3fb..0000000 --- a/sc-f-gateway-predicate/target/classes/application.yml +++ /dev/null @@ -1,84 +0,0 @@ -server: - port: 8081 -spring: - profiles: - active: query_route - ---- -spring: - cloud: - gateway: - routes: - - id: after_route - uri: http://httpbin.org:80/get - predicates: - - After=2017-01-20T17:42:47.789-07:00[America/Denver] - profiles: after_route - ---- -spring: - cloud: - gateway: - routes: - - id: header_route - uri: http://httpbin.org:80/get - predicates: - - Header=X-Request-Id, \d+ - profiles: header_route - ---- -spring: - cloud: - gateway: - routes: - - id: cookie_route - uri: http://httpbin.org:80/get - predicates: - - Cookie=name, forezp - profiles: cookie_route - ---- -spring: - cloud: - gateway: - routes: - - id: host_route - uri: http://httpbin.org:80/get - predicates: - - Host=**.fangzhipeng.com - profiles: host_route - - ---- -spring: - cloud: - gateway: - routes: - - id: method_route - uri: http://httpbin.org:80/get - predicates: - - Method=GET - profiles: method_route - ---- -spring: - cloud: - gateway: - routes: - - id: path_route - uri: http://httpbin.org:80/get - predicates: - - Path=/foo/{segment} - profiles: path_route - ---- - -spring: - cloud: - gateway: - routes: - - id: query_route - uri: http://httpbin.org:80/get - predicates: - - Query=foo, ba. - profiles: query_route \ No newline at end of file diff --git a/sc-f-gateway-predicate/target/classes/gateway/Application.class b/sc-f-gateway-predicate/target/classes/gateway/Application.class deleted file mode 100644 index 99f5bc566a6d8d2f4e13809a3727a48d8e3f2f2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 736 zcmZ`%%TC)s6g?9H2`1%{@GNxEUC5%dsSuJYB#6|NRU}fSi>}6Ia0i^3XgntHS*)nK z=m+poh&u*>7siWwbzkS)d&Uos|NaB`icbNW*l1xhz!tV!*kM@srnGWL40HYcF++1` z&LzW2q_q4|Ok!z&ia4W8H!_LH#=po#zGwSfXf=;t!PZ!v`f8(C#({e=+y#Z9bq1(4(&P3Pu~tSfPA_kiA_) Mm%Q)okzWU%0J1Q_C;$Ke -- Gitee From b777c55b799964125da5eabc1460dc423418716a Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sun, 8 Mar 2020 09:52:39 +0800 Subject: [PATCH 13/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sc-f-gateway-filter/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 sc-f-gateway-filter/.gitignore diff --git a/sc-f-gateway-filter/.gitignore b/sc-f-gateway-filter/.gitignore new file mode 100644 index 0000000..797b705 --- /dev/null +++ b/sc-f-gateway-filter/.gitignore @@ -0,0 +1 @@ +*.iml \ No newline at end of file -- Gitee From 6a9647c61d176601b9181d79b90bf5613398f431 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Sun, 8 Mar 2020 09:55:40 +0800 Subject: [PATCH 14/23] 'update-gitignore' --- sc-f-gateway-filter/sc-f-gateway-filter.iml | 119 -------------------- 1 file changed, 119 deletions(-) delete mode 100644 sc-f-gateway-filter/sc-f-gateway-filter.iml diff --git a/sc-f-gateway-filter/sc-f-gateway-filter.iml b/sc-f-gateway-filter/sc-f-gateway-filter.iml deleted file mode 100644 index 3b4b571..0000000 --- a/sc-f-gateway-filter/sc-f-gateway-filter.iml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- Gitee From b74412bffa8f36bf356b8c1200f5f40c53cd9bbf Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Mon, 9 Mar 2020 15:42:50 +0800 Subject: [PATCH 15/23] =?UTF-8?q?=E4=BC=98=E5=8C=96spring-cloud-gateway-fi?= =?UTF-8?q?lter=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/gateway/Application.java | 44 +++--- .../RequestTimeGatewayFilterFactory.java | 148 +++++++++--------- ...tChangeRequestUriGatewayFilterFactory.java | 20 +-- .../src/main/resources/application.yml | 13 ++ 4 files changed, 120 insertions(+), 105 deletions(-) diff --git a/sc-f-gateway-filter/src/main/java/gateway/Application.java b/sc-f-gateway-filter/src/main/java/gateway/Application.java index 7183574..137ac6a 100644 --- a/sc-f-gateway-filter/src/main/java/gateway/Application.java +++ b/sc-f-gateway-filter/src/main/java/gateway/Application.java @@ -3,6 +3,8 @@ package gateway; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; import org.springframework.context.annotation.Bean; import org.springframework.web.bind.annotation.RestController; @@ -15,30 +17,30 @@ public class Application { } -// @Bean -// public RouteLocator customerRouteLocator(RouteLocatorBuilder builder) { -// -// return builder.routes() -// .route(r -> r.path("/customer/**") -// .filters(f -> f.filter(new RequestTimeFilter()) -// .addResponseHeader("X-Response-Default-Foo", "Default-Bar")) -// .uri("http://httpbin.org:80/get") -// .order(0) -// .id("customer_filter_router") -// ) -// .build(); -// -// } - -// @Bean -// public TokenFilter tokenFilter(){ -// return new TokenFilter(); -// } + @Bean + public RouteLocator customerRouteLocator(RouteLocatorBuilder builder) { + + return builder.routes() + .route(r -> r.path("/customer/**") + .filters(f -> f.filter(new RequestTimeFilter()) + .addResponseHeader("X-Response-Default-Foo", "Default-Bar")) + .uri("http://httpbin.org:80/get") + .order(0) + .id("customer_filter_router") + ) + .build(); + } @Bean - public RequestTimeGatewayFilterFactory elapsedGatewayFilterFactory() { - return new RequestTimeGatewayFilterFactory(); + public TokenFilter tokenFilter(){ + return new TokenFilter(); } + + +// @Bean +// public RequestTimeGatewayFilterFactory elapsedGatewayFilterFactory() { +// return new RequestTimeGatewayFilterFactory(); +// } } diff --git a/sc-f-gateway-filter/src/main/java/gateway/RequestTimeGatewayFilterFactory.java b/sc-f-gateway-filter/src/main/java/gateway/RequestTimeGatewayFilterFactory.java index af374eb..a1a7a00 100644 --- a/sc-f-gateway-filter/src/main/java/gateway/RequestTimeGatewayFilterFactory.java +++ b/sc-f-gateway-filter/src/main/java/gateway/RequestTimeGatewayFilterFactory.java @@ -1,74 +1,74 @@ -package gateway; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.cloud.gateway.filter.GatewayFilter; -import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; -import reactor.core.publisher.Mono; - -import java.util.Arrays; -import java.util.List; - -/** - * Email miles02@163.com - * - * @author fangzhipeng - * create 2018-11-16 - **/ -public class RequestTimeGatewayFilterFactory extends AbstractGatewayFilterFactory { - - - private static final Log log = LogFactory.getLog(GatewayFilter.class); - private static final String REQUEST_TIME_BEGIN = "requestTimeBegin"; - private static final String KEY = "withParams"; - - @Override - public List shortcutFieldOrder() { - return Arrays.asList(KEY); - } - - public RequestTimeGatewayFilterFactory() { - super(Config.class); - } - - @Override - public GatewayFilter apply(Config config) { - return (exchange, chain) -> { - exchange.getAttributes().put(REQUEST_TIME_BEGIN, System.currentTimeMillis()); - return chain.filter(exchange).then( - Mono.fromRunnable(() -> { - Long startTime = exchange.getAttribute(REQUEST_TIME_BEGIN); - if (startTime != null) { - StringBuilder sb = new StringBuilder(exchange.getRequest().getURI().getRawPath()) - .append(": ") - .append(System.currentTimeMillis() - startTime) - .append("ms"); - if (config.isWithParams()) { - sb.append(" params:").append(exchange.getRequest().getQueryParams()); - } - log.info(sb.toString()); - } - }) - ); - }; - } - - - - - - - public static class Config { - - private boolean withParams; - - public boolean isWithParams() { - return withParams; - } - - public void setWithParams(boolean withParams) { - this.withParams = withParams; - } - - } -} +//package gateway; +// +//import org.apache.commons.logging.Log; +//import org.apache.commons.logging.LogFactory; +//import org.springframework.cloud.gateway.filter.GatewayFilter; +//import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +//import reactor.core.publisher.Mono; +// +//import java.util.Arrays; +//import java.util.List; +// +///** +// * Email miles02@163.com +// * +// * @author fangzhipeng +// * create 2018-11-16 +// **/ +//public class RequestTimeGatewayFilterFactory extends AbstractGatewayFilterFactory { +// +// +// private static final Log log = LogFactory.getLog(GatewayFilter.class); +// private static final String REQUEST_TIME_BEGIN = "requestTimeBegin"; +// private static final String KEY = "withParams"; +// +// @Override +// public List shortcutFieldOrder() { +// return Arrays.asList(KEY); +// } +// +// public RequestTimeGatewayFilterFactory() { +// super(Config.class); +// } +// +// @Override +// public GatewayFilter apply(Config config) { +// return (exchange, chain) -> { +// exchange.getAttributes().put(REQUEST_TIME_BEGIN, System.currentTimeMillis()); +// return chain.filter(exchange).then( +// Mono.fromRunnable(() -> { +// Long startTime = exchange.getAttribute(REQUEST_TIME_BEGIN); +// if (startTime != null) { +// StringBuilder sb = new StringBuilder(exchange.getRequest().getURI().getRawPath()) +// .append(": ") +// .append(System.currentTimeMillis() - startTime) +// .append("ms"); +// if (config.isWithParams()) { +// sb.append(" params:").append(exchange.getRequest().getQueryParams()); +// } +// log.info(sb.toString()); +// } +// }) +// ); +// }; +// } +// +// +// +// +// +// +// public static class Config { +// +// private boolean withParams; +// +// public boolean isWithParams() { +// return withParams; +// } +// +// public void setWithParams(boolean withParams) { +// this.withParams = withParams; +// } +// +// } +//} diff --git a/sc-f-gateway-filter/src/main/java/org/springframework/cloud/gateway/filter/factory/AbstractChangeRequestUriGatewayFilterFactory.java b/sc-f-gateway-filter/src/main/java/org/springframework/cloud/gateway/filter/factory/AbstractChangeRequestUriGatewayFilterFactory.java index 74928f5..e644454 100644 --- a/sc-f-gateway-filter/src/main/java/org/springframework/cloud/gateway/filter/factory/AbstractChangeRequestUriGatewayFilterFactory.java +++ b/sc-f-gateway-filter/src/main/java/org/springframework/cloud/gateway/filter/factory/AbstractChangeRequestUriGatewayFilterFactory.java @@ -1,10 +1,10 @@ -package org.springframework.cloud.gateway.filter.factory; - -/** - * Email miles02@163.com - * - * @author fangzhipeng - * create 2018-12-04 - **/ -public abstract class AbstractChangeRequestUriGatewayFilterFactory extends AbstractGatewayFilterFactory { -} +//package org.springframework.cloud.gateway.filter.factory; +// +///** +// * Email miles02@163.com +// * +// * @author fangzhipeng +// * create 2018-12-04 +// **/ +//public abstract class AbstractChangeRequestUriGatewayFilterFactory extends AbstractGatewayFilterFactory { +//} diff --git a/sc-f-gateway-filter/src/main/resources/application.yml b/sc-f-gateway-filter/src/main/resources/application.yml index 144b15c..37a6c74 100644 --- a/sc-f-gateway-filter/src/main/resources/application.yml +++ b/sc-f-gateway-filter/src/main/resources/application.yml @@ -56,3 +56,16 @@ spring: predicates: - After=2017-01-20T17:42:47.789-07:00[America/Denver] profiles: request_time_route + +--- +spring: + cloud: + gateway: + routes: + - id: elapse_route + uri: http://httpbin.org:80/get + filters: + - RequestTime=false + predicates: + - After=2017-01-20T17:42:47.789-07:00[America/Denver] + profiles: elapse_route \ No newline at end of file -- Gitee From 97444a200d47d010d44e8f5aa3a5ee55b2165faa Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Mon, 9 Mar 2020 15:55:08 +0800 Subject: [PATCH 16/23] =?UTF-8?q?=E4=BC=98=E5=8C=96spring-cloud-gateway-li?= =?UTF-8?q?miter=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sc-f-gateway-limiter/.gitignore | 1 + sc-f-gateway-limiter/pom.xml | 2 +- sc-f-gateway-limiter/sc-f-gateway-filter.iml | 107 ------------------- 3 files changed, 2 insertions(+), 108 deletions(-) create mode 100644 sc-f-gateway-limiter/.gitignore delete mode 100644 sc-f-gateway-limiter/sc-f-gateway-filter.iml diff --git a/sc-f-gateway-limiter/.gitignore b/sc-f-gateway-limiter/.gitignore new file mode 100644 index 0000000..797b705 --- /dev/null +++ b/sc-f-gateway-limiter/.gitignore @@ -0,0 +1 @@ +*.iml \ No newline at end of file diff --git a/sc-f-gateway-limiter/pom.xml b/sc-f-gateway-limiter/pom.xml index f30a006..3521909 100644 --- a/sc-f-gateway-limiter/pom.xml +++ b/sc-f-gateway-limiter/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.forezp - sc-f-gateway-filter + sc-f-gateway-limiter 0.1.0 diff --git a/sc-f-gateway-limiter/sc-f-gateway-filter.iml b/sc-f-gateway-limiter/sc-f-gateway-filter.iml deleted file mode 100644 index d5ad85a..0000000 --- a/sc-f-gateway-limiter/sc-f-gateway-filter.iml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- Gitee From db225eff20ce8d3c8ee889786beacee921f6d96b Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Mon, 9 Mar 2020 19:55:43 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E4=BC=98=E5=8C=96spring-cloud-gateway-li?= =?UTF-8?q?miter=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../target/classes/gateway/Application.class | Bin 5523 -> 0 bytes sc-f-gateway-limiter/.gitignore | 3 ++- .../src/main/resources/application.yml | 2 +- .../target/classes/application.yml | 25 ------------------ .../target/classes/gateway/Application.class | Bin 2487 -> 0 bytes .../classes/gateway/HostAddrKeyResolver.class | Bin 1265 -> 0 bytes .../classes/gateway/UriKeyResolver.class | Bin 1126 -> 0 bytes 7 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 sc-f-gateway-first-sight/target/classes/gateway/Application.class delete mode 100644 sc-f-gateway-limiter/target/classes/application.yml delete mode 100644 sc-f-gateway-limiter/target/classes/gateway/Application.class delete mode 100644 sc-f-gateway-limiter/target/classes/gateway/HostAddrKeyResolver.class delete mode 100644 sc-f-gateway-limiter/target/classes/gateway/UriKeyResolver.class diff --git a/sc-f-gateway-first-sight/target/classes/gateway/Application.class b/sc-f-gateway-first-sight/target/classes/gateway/Application.class deleted file mode 100644 index fd138704a8749effe5ef3e9ca7500706188a8bfc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5523 zcmb_gX?qjb6@IU`k;ND*BDiG>hB~Pc!2^LN)FLFtiQ_af5DX?Q=`xZ=^5D^oGMd4t zZPLA2x}^J>rTe}lT@>oJY5TQLe^Z~ncV;Y&kq}nlgLJpEpL5SScmDm~wYLEr!@rW) zgEI=wCh;WBC9s&pd0a^I>{1d>`|AIeEA!%X5bR?_H) zlSCEIB;Y3T2x87(h9JdIBGna353fae<)|rfqsB1^OosEC~$EIz>ZZ zG-ukzX}^*;-1BgOEaGYIhPWX^HRTCFNEORioq zRvmXmD_D+S)Ye(M5?IUord2dtEkKnbdyac5+{+%=G?h3u^-vJ7wt735k+!S$Vy% zBCvPzK+ZMv0&Sud9M{mQe%>-`%e2>mV><*MUNpmdN52JQ}CRCI#a9Lg~+j7 zK5pBFJ8S8+nv9p1C);J~C|0)!I_nxm8Op|D)hP5DI}>sFsG6t>Jamg92#iF=uzky# zI4ba5@Au-d@S@I{mS?y{2Ss1WhEun8@CXCcrQzeldq^{_y4(ed4aL7y=A zQ?V2}B~ydI$&Rw+9f#N5_nc4#URiB1NRX#^5F^s#ove8@kLNm;Ww==tcVRCR^m>ks zkyY?16`#gunEhogo7OZr@QzP0RZky3tl+aMK8NS2krasD(5nlEx9k*aqeFNhg%>%z zl)@KOd=Xz#@MRS*<15_zs*11S>k7W1;+yyut(BQt4xKqwa4HJEt>QcQE&;!n!ow2z z`wCuB@hV6wLBQm%7&-nHvyC15^LVDEQjMo$F+$4JN%wXwX*h^{AHuyDR@I*db4FJC@>q6 zgn~B(7H^K7Zsz_WH|i3U=GGZjuG>I+A|jYg;t%+vz&&xJgkEP|xIPdF-G@K@ zUrozxEjfcad$GE}k+{_B%~vS3@0pfX^6i4`*R;84LeD&L8?DES6L?6#iX^!K+uQB4 zKKz-ygQCT@q=%4*hZ&8rt4qtoY;oDIdDmIF85>k4te@=Y;9hAn zNn30fgTgK&xDmFCL3H21VFKA(;KC+2%w=rYSmC=d>OC@AEy@GEiWs3X6Z*10KYL5o z4MJ%{o~Pfp$4Rco%91qtTkLxDLcyrgt+H9~U=*g$nqOgU7MST(wGG{n^t614gtfJm z@;5rW$*y-Fv~i=zO3m<2^Zh1Z#*NTSOE=f3=lVykTgi1UdIizFyg60fTb2gD#!9Xi zi_ueL-q87W>?~U>&-Wm0kolUA(oPmRbaRzMB0(q#Y@)Dj-b4!iqGAnySMfMbs5mbF z9+F+vtn8iMhld6Bx9Xc|UvX9pEf>7V*vsirvn{Zt(po9_2ctOWI4eFMJ^zWjIU*3Y zf%Cduw2azB2$^lSZ)|4+;`w^jh=XtbFl5;sH(t;q%CiieMbk5~3jQf@cbh>v=_7Dg zcR1{0`0e3m9$=WCc-Uw2f1E3gqu@B0c?;rAPWlK639X%UnbM#TLGdc3>M6+!>>hz`HTYeSrhW5MrEjhhsm-J?VjkgAEMcyGG_{ zK;a}2Od1$|g8-pmJLM^M5M?JuunS|&9xMEJR}wgOR_kKd&yA3AHo!=XoQmL z9p=bNiu-sr&iP@kq%uS4 zb3M+pi-ZcyaWJhmFtSEqDma>HAk|_shCzbv4TRZ3AB@t@X|APGVW3cO6O(c{RGXSSL6kn^0w2ntUEumOe_8(a^ZdPd z7SlA^BlrX!<@hwemwuk(U-35nMn#qgcZ{yPNcK6vVkSFAK1yvym#N5_wJqHuYcbB3E&I-lEonM4nED|GhBCYBa1#e z_p- zjyeyYQZZ;X*#zSULz{|GTbK96%{B7*DqR@40Hb-BrUlwafKYmZUKXvm~`W?{uwQS9bU3abG(^(;-8Y*dyZa_9 z-$GvGzF(3?P^ErmxOSpGY3E_M)ZGr3NjHP^HiI5%dO0vm-}h+d(a2~#lYa&FJN@W^ zeZs8~a1Q6`>oyJWK1OMF7GwB;R;=?avbJ{pBR%=o=-oW>w=x9+j<^>&WQlx`DGAja(Y3>EyL>4t=RZ&FFp9iWFErKf1t$lB$ND zjSW{x|C`@xamU;9WWbfkl1-{!S!2%Gl8%i}&sEaei4I*`NYY$n(eL1ni#!Sr=3LC< zu7i6n79brgx>&-pgZnNk{!n1*3>5^1Pl&uO?~rc=);ek72Rg3EHq^EXEVtUQzJaPM zD^Dpau-FOUEHSzAD%nkXA5)YN$QL>)Re^B=vJ~+o&oH61Pa#>k!AnW|yOfSJ`}u>DfA%(OJBFJ09jfJFklZgI#~Fjnr#%WO zn_L^>^!TvOXS@e~!8>u%+NJ!d$!iM!mzRWDIQ-Y(2f@FP3|k&PUR^#(wt{WX+-HbS zse6Fe-t=++gS>Z}0T{wCp9DrQ${BF8XeY4kYnE~UGPpD-P4{Qv*} diff --git a/sc-f-gateway-limiter/target/classes/gateway/UriKeyResolver.class b/sc-f-gateway-limiter/target/classes/gateway/UriKeyResolver.class deleted file mode 100644 index 84d074ba4df1a3106504c31abb23b4c1e1e6be9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1126 zcmb_b+iuf95IviwF-=@bFN8w5m21*Mx1c_eDldo%gv%wN<$3LHoehp1*6W1+6}$lL z10TRgA;wN3f)o{ykfoi=&K%Fonf?CbI_qr>OMpMadaRV<{TBu7fHvJ`i*b{@+>%!CxU&URca5NdDBuc!?NQG zBm3fr?`id19yMef1wE;243-|~46iFrq=1EjqFv>36&@T^>tK(Y%?7x6*y` z!E1@om$j;+rSMFoxff~4yNMg9xJ9A6Q5X^W899t(c=+$=3^PsThr%S98kGOLzHO&1 zdV&Yk32&OT>sp;^E;ge?dvZsmQ(gRhU>j+MjTsaz+_G^ScP!ksQ9;$hnvHebvvA+W z1~@}`^2`~|{rc@ow=F%xP@gn;FNl%@K0-NEfuX@_A~H}NW%wA644abxPNRVb9wJd5eT#&#ltrH>t(<8Wegd^MJ>mcW -- Gitee From a455544b7fec194c83fb7288ecf130a9f3063522 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Tue, 10 Mar 2020 15:41:12 +0800 Subject: [PATCH 18/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9spring-boot-admin?= =?UTF-8?q?=E9=82=AE=E7=AE=B1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin-server/src/main/resources/application.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml b/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml index a412b4e..02b3a46 100644 --- a/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml +++ b/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml @@ -30,7 +30,7 @@ management: spring.mail.host: smtp.163.com -spring.mail.username: miles02 -spring.mail.password: -spring.boot.admin.notify.mail.to: 124746406@qq.com +spring.mail.username: 13486032976@163.com +spring.mail.password: qsx741olm +spring.boot.admin.notify.mail.to: 1186827476@qq.com -- Gitee From fbf5168dfc04bb468f2b9e6d25612f2f55c2a078 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Tue, 10 Mar 2020 15:42:09 +0800 Subject: [PATCH 19/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9spring-boot-admin?= =?UTF-8?q?=E9=82=AE=E7=AE=B1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin-server/src/main/resources/application.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml b/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml index 02b3a46..5c11875 100644 --- a/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml +++ b/sc-f-boot-admin-cloud/admin-server/src/main/resources/application.yml @@ -31,6 +31,7 @@ management: spring.mail.host: smtp.163.com spring.mail.username: 13486032976@163.com +# 这里的密码不是登录密码,而是授权码 spring.mail.password: qsx741olm spring.boot.admin.notify.mail.to: 1186827476@qq.com -- Gitee From 7ddff085462015ac6c5f76c88e78b51de18e4a4f Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Fri, 20 Mar 2020 12:28:38 +0800 Subject: [PATCH 20/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.idea/.gitignore b/.idea/.gitignore index 5ecbb78..29a3a06 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -9,3 +9,5 @@ /.name /encodings.xml /compiler.xml +uiDesigner.xml +inspectionProfiles \ No newline at end of file -- Gitee From 34299ac09ae3816f232b2ae674b25b7a5bfddc5e Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Fri, 20 Mar 2020 12:29:00 +0800 Subject: [PATCH 21/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0lombok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nacos-discovery-sentinel/nacos-provider/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/pom.xml b/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/pom.xml index 7155d0b..e5767e5 100644 --- a/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/pom.xml +++ b/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/pom.xml @@ -44,6 +44,11 @@ spring-cloud-starter-alibaba-sentinel 0.9.0.RELEASE + + org.projectlombok + lombok + 1.18.12 + -- Gitee From d5627bbd9dcfbb6a3306e9cf1c4f48d309d8124e Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Fri, 20 Mar 2020 19:36:16 +0800 Subject: [PATCH 22/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=99=90=E6=B5=81?= =?UTF-8?q?=E9=99=8D=E7=BA=A7=E5=92=8C=E7=86=94=E6=96=AD=E9=99=8D=E7=BA=A7?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/forezp/web/ProviderController.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/src/main/java/com/forezp/web/ProviderController.java b/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/src/main/java/com/forezp/web/ProviderController.java index 44d7e8d..9c7b663 100644 --- a/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/src/main/java/com/forezp/web/ProviderController.java +++ b/springcloud-alibaba/nacos-discovery-sentinel/nacos-provider/src/main/java/com/forezp/web/ProviderController.java @@ -1,6 +1,8 @@ package com.forezp.web; import com.alibaba.csp.sentinel.annotation.SentinelResource; +import com.alibaba.csp.sentinel.slots.block.BlockException; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,7 @@ import java.util.List; */ @RestController +@Slf4j public class ProviderController { Logger logger= LoggerFactory.getLogger(ProviderController.class); @@ -27,12 +30,27 @@ public class ProviderController { @GetMapping("/hi") - @SentinelResource("hi") + @SentinelResource(value = "hi",blockHandler = "blockHandler",fallback = "fallbackHandler") public String hi(@RequestParam(value = "name",defaultValue = "forezp",required = false)String name){ - + if (name.equals("123")){ + throw new RuntimeException("发生异常"); + } return "hi "+name; } + // 限流降级处理 + public String blockHandler(String name, BlockException ex) { + log.error( "blockHandler:" + name, ex); + System.out.println("blockHandler:" + name); + return "blockHandler"; + } + + // 熔断降级处理 + public String fallbackHandler(String name) { + log.error("fallbackHandler:" + name); + System.out.println("fallbackHandler:" + name); + return "fallback"; + } @GetMapping("/services") public String getServices(){ -- Gitee From 6063f90d0cde06f12bfd275d21998571296f6d37 Mon Sep 17 00:00:00 2001 From: yanghaojie <13486032976@163.com> Date: Tue, 24 Mar 2020 16:47:49 +0800 Subject: [PATCH 23/23] =?UTF-8?q?springcloud=E6=95=B4=E5=90=88sentinel?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0README=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nacos-discovery-sentinel/.gitignore | 1 - .../nacos-discovery-sentinel/README.md | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 springcloud-alibaba/nacos-discovery-sentinel/README.md diff --git a/springcloud-alibaba/nacos-discovery-sentinel/.gitignore b/springcloud-alibaba/nacos-discovery-sentinel/.gitignore index 153c933..4a45303 100644 --- a/springcloud-alibaba/nacos-discovery-sentinel/.gitignore +++ b/springcloud-alibaba/nacos-discovery-sentinel/.gitignore @@ -1,4 +1,3 @@ -HELP.md /target/ !.mvn/wrapper/maven-wrapper.jar diff --git a/springcloud-alibaba/nacos-discovery-sentinel/README.md b/springcloud-alibaba/nacos-discovery-sentinel/README.md new file mode 100644 index 0000000..416bbe1 --- /dev/null +++ b/springcloud-alibaba/nacos-discovery-sentinel/README.md @@ -0,0 +1,18 @@ +# Getting Started +## spring cloud alibaba教程:Sentinel的使用(限流,熔断降级,比Hystrix更细粒度) +https://note.wiz.cn/web/web?dc=7b1b08ac-e891-4c37-9114-518dbf7fc935&kb=&cmd=km%2C + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/maven-plugin/) +* [Spring Web](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/) + -- Gitee