diff --git a/cloud-consumer-hystrix-dashboard9001/cloud-consumer-hystrix-dashboard9001.iml b/cloud-consumer-hystrix-dashboard9001/cloud-consumer-hystrix-dashboard9001.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/cloud-consumer-hystrix-dashboard9001/cloud-consumer-hystrix-dashboard9001.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/cloud-consumer-hystrix-dashboard9001/pom.xml b/cloud-consumer-hystrix-dashboard9001/pom.xml
new file mode 100644
index 0000000..7ec8364
--- /dev/null
+++ b/cloud-consumer-hystrix-dashboard9001/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+ springcloud2020
+ com.yanzhen.springcloud
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ cloud-consumer-hystrix-dashboard9001
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-hystrix-dashboard
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
\ No newline at end of file
diff --git a/cloud-consumer-hystrix-dashboard9001/src/main/java/com/yanzhen/springcloud/HystrixDashboardMain9001.java b/cloud-consumer-hystrix-dashboard9001/src/main/java/com/yanzhen/springcloud/HystrixDashboardMain9001.java
new file mode 100644
index 0000000..c945bca
--- /dev/null
+++ b/cloud-consumer-hystrix-dashboard9001/src/main/java/com/yanzhen/springcloud/HystrixDashboardMain9001.java
@@ -0,0 +1,13 @@
+package com.yanzhen.springcloud;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
+
+@SpringBootApplication
+@EnableHystrixDashboard
+public class HystrixDashboardMain9001 {
+ public static void main(String[] args) {
+ SpringApplication.run(HystrixDashboardMain9001.class,args);
+ }
+}
diff --git a/cloud-consumer-hystrix-dashboard9001/src/main/resources/application.yml b/cloud-consumer-hystrix-dashboard9001/src/main/resources/application.yml
new file mode 100644
index 0000000..3621202
--- /dev/null
+++ b/cloud-consumer-hystrix-dashboard9001/src/main/resources/application.yml
@@ -0,0 +1,2 @@
+server:
+ port: 9001
\ No newline at end of file
diff --git a/cloud-gateway-gateway9527/cloud-gateway-gateway9527.iml b/cloud-gateway-gateway9527/cloud-gateway-gateway9527.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/cloud-gateway-gateway9527/cloud-gateway-gateway9527.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/cloud-gateway-gateway9527/pom.xml b/cloud-gateway-gateway9527/pom.xml
new file mode 100644
index 0000000..d75027d
--- /dev/null
+++ b/cloud-gateway-gateway9527/pom.xml
@@ -0,0 +1,52 @@
+
+
+
+ springcloud2020
+ com.yanzhen.springcloud
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ cloud-gateway-gateway9527
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-gateway
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+
+ com.yanzhen.springcloud
+ cloud-api-common
+ 1.0-SNAPSHOT
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+
+
\ No newline at end of file
diff --git a/cloud-gateway-gateway9527/src/main/java/com/yanzhen/springcloud/GateWayMain9527.java b/cloud-gateway-gateway9527/src/main/java/com/yanzhen/springcloud/GateWayMain9527.java
new file mode 100644
index 0000000..dbe766e
--- /dev/null
+++ b/cloud-gateway-gateway9527/src/main/java/com/yanzhen/springcloud/GateWayMain9527.java
@@ -0,0 +1,13 @@
+package com.yanzhen.springcloud;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+
+@SpringBootApplication
+@EnableEurekaClient
+public class GateWayMain9527 {
+ public static void main(String[] args) {
+ SpringApplication.run(GateWayMain9527.class,args);
+ }
+}
diff --git a/cloud-gateway-gateway9527/src/main/java/com/yanzhen/springcloud/config/GateWayConfig.java b/cloud-gateway-gateway9527/src/main/java/com/yanzhen/springcloud/config/GateWayConfig.java
new file mode 100644
index 0000000..d08564d
--- /dev/null
+++ b/cloud-gateway-gateway9527/src/main/java/com/yanzhen/springcloud/config/GateWayConfig.java
@@ -0,0 +1,16 @@
+package com.yanzhen.springcloud.config;
+
+import org.springframework.cloud.gateway.route.RouteLocator;
+import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class GateWayConfig {
+ @Bean
+ public RouteLocator routeLocator(RouteLocatorBuilder routeLocatorBuilder){
+ RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
+ routes.route("yz",r -> r.path("/aaa").uri("http://qq.com")).build();
+ return routes.build();
+ }
+}
diff --git a/cloud-gateway-gateway9527/src/main/resources/application.yml b/cloud-gateway-gateway9527/src/main/resources/application.yml
new file mode 100644
index 0000000..314141c
--- /dev/null
+++ b/cloud-gateway-gateway9527/src/main/resources/application.yml
@@ -0,0 +1,33 @@
+server:
+ port: 9527
+
+
+eureka:
+ client:
+ register-with-eureka: true
+ service-url:
+ defaultZone: http://localhost:7001/eureka
+ fetch-registry: true
+ instance:
+ hostname: cloud-gateway-service
+spring:
+ application:
+ name: cloud-gateway
+ cloud:
+ gateway:
+ routes:
+ - id: payment_routh
+ uri: lb://CLOUD-PAYMENT-SERVICE
+ predicates:
+ - Path=/payment/get/**
+
+ - id: payment_routh2
+ uri: lb://CLOUD-PAYMENT-SERVICE
+ predicates:
+ - Path=/payment/lb
+# - After=2020-05-07T15:47:17.798+08:00[Asia/Shanghai]
+ - Cookie=yz,123
+ discovery:
+ locator:
+ enabled: true
+
diff --git a/cloud-gateway-gateway9527/src/test/java/Test1.java b/cloud-gateway-gateway9527/src/test/java/Test1.java
new file mode 100644
index 0000000..248fe2c
--- /dev/null
+++ b/cloud-gateway-gateway9527/src/test/java/Test1.java
@@ -0,0 +1,11 @@
+import org.junit.Test;
+
+import java.time.ZonedDateTime;
+
+public class Test1 {
+ @Test
+ public void test1(){
+ ZonedDateTime zonedDateTime = ZonedDateTime.now();
+ System.out.println(zonedDateTime);
+ }
+}
diff --git a/cloud-provider-hystrix-payment8001/src/main/java/com/yanzhen/springcloud/PaymentHystrixMain8001.java b/cloud-provider-hystrix-payment8001/src/main/java/com/yanzhen/springcloud/PaymentHystrixMain8001.java
index 6f14914..2b841d0 100644
--- a/cloud-provider-hystrix-payment8001/src/main/java/com/yanzhen/springcloud/PaymentHystrixMain8001.java
+++ b/cloud-provider-hystrix-payment8001/src/main/java/com/yanzhen/springcloud/PaymentHystrixMain8001.java
@@ -1,9 +1,12 @@
package com.yanzhen.springcloud;
+import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableEurekaClient
@@ -13,4 +16,15 @@ public class PaymentHystrixMain8001 {
public static void main(String[] args) {
SpringApplication.run(PaymentHystrixMain8001.class,args);
}
+
+ //注册一个servlet才能使用hystrixdashboard
+ @Bean
+ public ServletRegistrationBean getServlet(){
+ HystrixMetricsStreamServlet hystrixMetricsStreamServlet = new HystrixMetricsStreamServlet();
+ ServletRegistrationBean servletServletRegistrationBean = new ServletRegistrationBean<>(hystrixMetricsStreamServlet);
+ servletServletRegistrationBean.setLoadOnStartup(1);
+ servletServletRegistrationBean.addUrlMappings("/hystrix.stream");
+ servletServletRegistrationBean.setName("yanzhen.hystrix");
+ return servletServletRegistrationBean;
+ }
}
diff --git a/pom.xml b/pom.xml
index 3848dc4..60addcf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,8 @@
cloud-consumer-feign-order80
cloud-provider-hystrix-payment8001
cloud-consumer-feign-hystrix-order80
+ cloud-consumer-hystrix-dashboard9001
+ cloud-gateway-gateway9527
pom