├── 10-1 构建消息驱动的微服务 └── hellostream │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── hellostream │ │ │ ├── HelloController.java │ │ │ ├── HellostreamApplication.java │ │ │ ├── MsgReceiver.java │ │ │ ├── MsgReceiver2.java │ │ │ └── MyChannel.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── hellostream │ └── HellostreamApplicationTests.java ├── 10-2 Spring Cloud Stream 深入实践 └── streamdemo │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── streamdemo │ │ │ ├── DelayMessageRecevier.java │ │ │ ├── DelayMsgChannel.java │ │ │ ├── DelayMsgController.java │ │ │ ├── MailService.java │ │ │ ├── RegChannel.java │ │ │ ├── RegController.java │ │ │ ├── RegService.java │ │ │ ├── SendVerifyCodeService.java │ │ │ └── StreamdemoApplication.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ └── mailtemplate.html │ └── test │ └── java │ └── com │ └── justdojava │ └── streamdemo │ └── StreamdemoApplicationTests.java ├── 12-2 Zipkin 实践 └── zipkin │ ├── consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── justdojava │ │ │ │ └── consumer │ │ │ │ ├── ConsumerApplication.java │ │ │ │ └── UseHelloController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── org │ │ └── justdojava │ │ └── consumer │ │ └── ConsumerApplicationTests.java │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── justdojava │ │ │ └── provider │ │ │ ├── HelloController.java │ │ │ └── ProviderApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── justdojava │ └── provider │ └── ProviderApplicationTests.java ├── 13-1 Spring Boot Admin 介绍 └── monitor │ ├── adminclient │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── adminclient │ │ │ │ └── AdminclientApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── adminclient │ │ └── AdminclientApplicationTests.java │ ├── adminserver │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── adminserver │ │ │ │ └── AdminserverApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── adminserver │ │ └── AdminserverApplicationTests.java │ └── pom.xml ├── 13-2 Spring Boot Admin 实践 └── monitor │ ├── adminclient │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── adminclient │ │ │ │ └── AdminclientApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── adminclient │ │ └── AdminclientApplicationTests.java │ ├── adminserver │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── adminserver │ │ │ │ └── AdminserverApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── adminserver │ │ └── AdminserverApplicationTests.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.java │ └── pom.xml ├── 14-2 Nacos 基础用法 ├── nacos-client │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── nacosclient │ │ │ │ ├── HelloController.java │ │ │ │ └── NacosClientApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── nacosclient │ │ └── NacosClientApplicationTests.java └── nacos │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── nacos │ │ │ ├── HelloController.java │ │ │ └── NacosApplication.java │ └── resources │ │ ├── application.properties │ │ └── bootstrap.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── nacos │ └── NacosApplicationTests.java ├── 14-3 Sentinel 基本用法 └── sentinel │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── sentinel │ │ │ ├── HelloController.java │ │ │ └── SentinelApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── sentinel │ └── SentinelApplicationTests.java ├── 2-3 Spring Boot 的设计理念和简单实践 └── hello │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── hello │ │ │ ├── HelloApplication.java │ │ │ └── HelloController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── hello │ └── HelloApplicationTests.java ├── 3-1 Eureka 服务注册中心的搭建 ├── eureka-cluster │ ├── eureka-a │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaAApplication.java │ │ │ └── resources │ │ │ └── application.properties │ ├── eureka-b │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaBApplication.java │ │ │ └── resources │ │ │ └── application.properties │ ├── eureka-c │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaCApplication.java │ │ │ └── resources │ │ │ └── application.properties │ └── pom.xml └── eureka │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplication.java │ └── resources │ └── application.properties ├── 3-5 Consul 架构原理和实践 └── consul │ ├── consul-consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── consul │ │ │ ├── ConsulConsummerApplication.java │ │ │ └── controller │ │ │ └── CallHelloController.java │ │ └── resources │ │ └── application.properties │ ├── consul-provider-2 │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── consul │ │ │ ├── ConsulProviderTwoApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ │ └── resources │ │ └── application.properties │ ├── consul-provider │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── consul │ │ │ ├── ConsulProviderApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ │ └── resources │ │ └── application.properties │ └── pom.xml ├── 4-1 服务注册与消费 └── ServiceRegistry │ ├── consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── consumer │ │ │ │ ├── ConsumerApplication.java │ │ │ │ └── UseHelloController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── consumer │ │ └── ConsumerApplicationTests.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.java │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── provider │ │ │ ├── HelloController.java │ │ │ └── ProviderApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── provider │ └── ProviderApplicationTests.java ├── 4-2 RestTemplate 使用详解 └── RestTemplate │ ├── commons │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── commons │ │ └── User.java │ ├── consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── consumer │ │ │ │ ├── ConsumerApplication.java │ │ │ │ └── UseHelloController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── consumer │ │ └── ConsumerApplicationTests.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.java │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── provider │ │ │ ├── HelloController.java │ │ │ ├── ProviderApplication.java │ │ │ └── UserController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── provider │ └── ProviderApplicationTests.java ├── 4-3 服务请求负载均衡 └── Loadbalancer │ ├── consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── consumer │ │ │ │ ├── ConsumerApplication.java │ │ │ │ └── UseHelloController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── consumer │ │ └── ConsumerApplicationTests.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.java │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── provider │ │ │ ├── HelloController.java │ │ │ └── ProviderApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── provider │ └── ProviderApplicationTests.java ├── 5-1 声明式服务调用 Feign └── Feign │ ├── commons │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── commons │ │ └── User.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.java │ ├── feign-consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── feignconsumer │ │ │ │ ├── FeignConsumerApplication.java │ │ │ │ ├── HelloController.java │ │ │ │ └── HelloService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── feignconsumer │ │ └── FeignConsumerApplicationTests.java │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── provider │ │ │ ├── HelloController.java │ │ │ ├── ProviderApplication.java │ │ │ └── UserController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── provider │ └── ProviderApplicationTests.java ├── 5-2 Feign 中的继承、日志与数据压缩 └── FeignAdvanced │ ├── commons │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── commons │ │ └── HelloService.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── eureka │ │ │ │ └── EurekaApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.java │ ├── feign-consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── feignconsumer │ │ │ │ ├── FeignConsumerApplication.java │ │ │ │ ├── FeignHelloService.java │ │ │ │ └── UseHelloController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── feignconsumer │ │ └── FeignConsumerApplicationTests.java │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── provider │ │ │ ├── HelloController.java │ │ │ └── ProviderApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── provider │ └── ProviderApplicationTests.java ├── 6-1 Resilience4j 基本用法详解 └── Resilience4j │ ├── pom.xml │ └── src │ └── test │ └── java │ └── com │ └── justdojava │ └── resilience4j │ ├── BulkheadTest.java │ ├── CacheTest.java │ ├── CircuitBreakerTest.java │ ├── ReteLimiterTest.java │ ├── RetryTest.java │ └── TimeLimiterTest.java ├── 6-2 Resilience4j 在微服务中的应用 └── Resilience4j-SpringBoot │ ├── consumer │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── consumer │ │ │ │ ├── ConsumerApplication.java │ │ │ │ ├── HelloService.java │ │ │ │ ├── HelloServiceCircuitBreaker.java │ │ │ │ ├── HelloServiceRateLimiter.java │ │ │ │ ├── IgnoredException.java │ │ │ │ ├── RecordFailurePredicate.java │ │ │ │ └── UseHelloController.java │ │ └── resources │ │ │ ├── application-circuitbreaker.yml │ │ │ ├── application-retry.yml │ │ │ └── application.yml │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── consumer │ │ └── ConsumerApplicationTests.java │ ├── eureka │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── eureka │ │ │ │ │ └── EurekaApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── eureka │ │ │ └── EurekaApplicationTests.java │ └── target │ │ ├── classes │ │ ├── application.properties │ │ └── com │ │ │ └── justdojava │ │ │ └── eureka │ │ │ └── EurekaApplication.class │ │ └── test-classes │ │ └── com │ │ └── justdojava │ │ └── eureka │ │ └── EurekaApplicationTests.class │ ├── pom.xml │ └── provider │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── provider │ │ │ │ ├── HelloController.java │ │ │ │ └── ProviderApplication.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── provider │ │ └── ProviderApplicationTests.java │ └── target │ ├── classes │ ├── application.properties │ └── com │ │ └── justdojava │ │ └── provider │ │ ├── HelloController.class │ │ └── ProviderApplication.class │ └── test-classes │ └── com │ └── justdojava │ └── provider │ └── ProviderApplicationTests.class ├── 6-3 Micrometer 实现微服务监控 └── micrometer │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── micrometer │ │ │ ├── HelloController.java │ │ │ └── MicrometerApplication.java │ └── resources │ │ └── application.yaml │ └── test │ └── java │ └── com │ └── justdojava │ └── micrometer │ └── MicrometerApplicationTests.java ├── 7-2 Spring Cloud Gateway 快速实践 ├── spring-cloud-gateway-eureka │ ├── consumer │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── consumer │ │ │ │ │ ├── ConsumerApplication.java │ │ │ │ │ └── UseHelloController.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── consumer │ │ │ └── ConsumerApplicationTests.java │ ├── eureka │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── eureka │ │ │ │ │ └── EurekaApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── eureka │ │ │ └── EurekaApplicationTests.java │ ├── gateway │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── gateway │ │ │ │ └── GatewayApplication.java │ │ │ └── resources │ │ │ └── application.yml │ ├── pom.xml │ ├── provider-1 │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── provider │ │ │ │ │ ├── HelloController.java │ │ │ │ │ └── ProviderApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── provider │ │ │ └── ProviderApplicationTests.java │ └── provider-2 │ │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── justdojava │ │ │ │ └── provider │ │ │ │ ├── HelloController.java │ │ │ │ └── ProviderApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── justdojava │ │ └── provider │ │ └── ProviderApplicationTests.java └── spring-cloud-gateway │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── justdojava │ │ └── gateway │ │ └── GatewayApplication.java │ └── resources │ └── application.yml ├── 8-1 初识 Spring Cloud Config ├── CloudConfig │ ├── config_client │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_client │ │ │ │ │ ├── ConfigClientApplication.java │ │ │ │ │ └── HelloController.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── bootstrap.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_client │ │ │ └── ConfigClientApplicationTests.java │ ├── config_server │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_server │ │ │ │ │ └── ConfigServerApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_server │ │ │ └── ConfigServerApplicationTests.java │ └── pom.xml └── configRepo │ └── client1 │ ├── client1-dev.properties │ ├── client1-prod.properties │ └── client1-test.properties ├── 8-2 Spring Cloud Config 中配置文件的加密与解密 ├── CloudConfig │ ├── config_client │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_client │ │ │ │ │ ├── ConfigClientApplication.java │ │ │ │ │ └── HelloController.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── bootstrap.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_client │ │ │ └── ConfigClientApplicationTests.java │ ├── config_server │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_server │ │ │ │ │ └── ConfigServerApplication.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ ├── bootstrap.properties │ │ │ │ └── config-server.keystore │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_server │ │ │ └── ConfigServerApplicationTests.java │ └── pom.xml └── configRepo │ └── client1 │ ├── client1-dev.properties │ ├── client1-prod.properties │ └── client1-test.properties ├── 8-3 Spring Cloud Config 服务化、动态刷新与重试 ├── CloudConfig │ ├── config_client │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_client │ │ │ │ │ ├── ConfigClientApplication.java │ │ │ │ │ └── HelloController.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── bootstrap.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_client │ │ │ └── ConfigClientApplicationTests.java │ ├── config_server │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_server │ │ │ │ │ └── ConfigServerApplication.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ ├── bootstrap.properties │ │ │ │ └── config-server.keystore │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_server │ │ │ └── ConfigServerApplicationTests.java │ ├── eureka │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── eureka │ │ │ │ │ └── EurekaApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── eureka │ │ │ └── EurekaApplicationTests.java │ └── pom.xml └── configRepo │ └── client1 │ ├── client1-dev.properties │ ├── client1-prod.properties │ └── client1-test.properties ├── 9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka ├── CloudConfig │ ├── config_client │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_client │ │ │ │ │ ├── ConfigClientApplication.java │ │ │ │ │ └── HelloController.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── bootstrap.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_client │ │ │ └── ConfigClientApplicationTests.java │ ├── config_server │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── config_server │ │ │ │ │ ├── ConfigServerApplication.java │ │ │ │ │ └── SecurityConfig.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ ├── bootstrap.properties │ │ │ │ └── config-server.keystore │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── config_server │ │ │ └── ConfigServerApplicationTests.java │ ├── eureka │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── justdojava │ │ │ │ │ └── eureka │ │ │ │ │ └── EurekaApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── justdojava │ │ │ └── eureka │ │ │ └── EurekaApplicationTests.java │ └── pom.xml ├── configRepo │ └── client1 │ │ ├── client1-dev.properties │ │ ├── client1-prod.properties │ │ └── client1-test.properties └── rabbitmq │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── justdojava │ │ │ └── rabbitmq │ │ │ ├── DirectReceiver.java │ │ │ ├── FanoutReceiver.java │ │ │ ├── HeaderReceiver.java │ │ │ ├── RabbitDirectConfig.java │ │ │ ├── RabbitFanoutConfig.java │ │ │ ├── RabbitHeaderConfig.java │ │ │ ├── RabbitTopicConfig.java │ │ │ ├── RabbitmqApplication.java │ │ │ └── TopicReceiver.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── justdojava │ └── rabbitmq │ └── RabbitmqApplicationTests.java └── README.md /10-1 构建消息驱动的微服务/hellostream/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/10-1 构建消息驱动的微服务/hellostream/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/main/java/com/justdojava/hellostream/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hellostream; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.integration.support.MessageBuilder; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/19 19:57 11 | */ 12 | @RestController 13 | public class HelloController { 14 | @Autowired 15 | MyChannel myChannel; 16 | 17 | @GetMapping("/test1") 18 | public void hello() { 19 | myChannel.output().send(MessageBuilder.withPayload("hello stream!").build()); 20 | } 21 | } -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/main/java/com/justdojava/hellostream/HellostreamApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hellostream; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HellostreamApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(HellostreamApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/main/java/com/justdojava/hellostream/MsgReceiver.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hellostream; 2 | 3 | import org.springframework.cloud.stream.annotation.EnableBinding; 4 | import org.springframework.cloud.stream.annotation.StreamListener; 5 | import org.springframework.cloud.stream.messaging.Sink; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019/5/19 16:01 10 | */ 11 | @EnableBinding(Sink.class) 12 | public class MsgReceiver { 13 | @StreamListener(Sink.INPUT) 14 | public void receive(Object playload) { 15 | System.out.println("Received:"+playload); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/main/java/com/justdojava/hellostream/MsgReceiver2.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hellostream; 2 | 3 | import org.springframework.cloud.stream.annotation.EnableBinding; 4 | import org.springframework.cloud.stream.annotation.StreamListener; 5 | import org.springframework.cloud.stream.messaging.Sink; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019/5/19 16:01 10 | */ 11 | @EnableBinding(MyChannel.class) 12 | public class MsgReceiver2 { 13 | @StreamListener(MyChannel.INPUT) 14 | public void receive(Object playload) { 15 | System.out.println("Received2:"+playload); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/main/java/com/justdojava/hellostream/MyChannel.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hellostream; 2 | 3 | import org.springframework.cloud.stream.annotation.Input; 4 | import org.springframework.cloud.stream.annotation.Output; 5 | import org.springframework.messaging.MessageChannel; 6 | import org.springframework.messaging.SubscribableChannel; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/19 16:58 11 | */ 12 | public interface MyChannel { 13 | String INPUT = "mychannel-input"; 14 | String OUTPUT = "mychannel-output"; 15 | 16 | @Output(OUTPUT) 17 | MessageChannel output(); 18 | 19 | @Input(INPUT) 20 | SubscribableChannel input(); 21 | } 22 | -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.rabbitmq.password=guest 2 | spring.rabbitmq.username=guest 3 | spring.rabbitmq.host=127.0.0.1 4 | spring.rabbitmq.port=5672 5 | 6 | spring.cloud.stream.bindings.mychannel-input.destination=javaboy-topic 7 | spring.cloud.stream.bindings.mychannel-output.destination=javaboy-topic 8 | 9 | spring.cloud.stream.bindings.mychannel-input.group=g1 10 | spring.cloud.stream.bindings.mychannel-output.group=g1 11 | 12 | spring.cloud.stream.bindings.mychannel-input.consumer.partitioned=true 13 | spring.cloud.stream.instance-count=2 14 | spring.cloud.stream.instance-index=0 15 | spring.cloud.stream.bindings.mychannel-output.producer.partition-key-expression=1 16 | spring.cloud.stream.bindings.mychannel-output.producer.partitionCount=2 -------------------------------------------------------------------------------- /10-1 构建消息驱动的微服务/hellostream/src/test/java/com/justdojava/hellostream/HellostreamApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hellostream; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.cloud.stream.annotation.EnableBinding; 8 | import org.springframework.cloud.stream.messaging.Source; 9 | import org.springframework.integration.support.MessageBuilder; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest 14 | public class HellostreamApplicationTests { 15 | 16 | @Test 17 | public void contextLoads() { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/10-2 Spring Cloud Stream 深入实践/streamdemo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/DelayMessageRecevier.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.cloud.stream.annotation.EnableBinding; 4 | import org.springframework.cloud.stream.annotation.StreamListener; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/22 16:26 11 | */ 12 | @EnableBinding(DelayMsgChannel.class) 13 | public class DelayMessageRecevier { 14 | @StreamListener(DelayMsgChannel.INPUT) 15 | public void recevier(String msg) { 16 | System.out.println("receive:" + msg + ">>>" + new Date()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/DelayMsgChannel.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.cloud.stream.annotation.Input; 4 | import org.springframework.cloud.stream.annotation.Output; 5 | import org.springframework.messaging.MessageChannel; 6 | import org.springframework.messaging.SubscribableChannel; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/22 16:23 11 | */ 12 | public interface DelayMsgChannel { 13 | String INPUT = "delay_msg_input"; 14 | String OUTPUT = "delay_msg_output"; 15 | 16 | @Input(INPUT) 17 | SubscribableChannel input(); 18 | 19 | @Output(OUTPUT) 20 | MessageChannel output(); 21 | } 22 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/DelayMsgController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.integration.support.MessageBuilder; 5 | import org.springframework.messaging.MessageChannel; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @Author 江南一点雨 13 | * @Date 2019/5/22 16:49 14 | */ 15 | @RestController 16 | public class DelayMsgController { 17 | @Autowired 18 | DelayMsgChannel delayMsgChannel; 19 | @GetMapping("/delay") 20 | public void hello() { 21 | System.out.println("message send:"+new Date()); 22 | delayMsgChannel.output().send(MessageBuilder.withPayload("delay message!").setHeader("x-delay", 3000).build()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/MailService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.mail.javamail.JavaMailSender; 5 | import org.springframework.mail.javamail.MimeMessageHelper; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.mail.MessagingException; 9 | import javax.mail.internet.MimeMessage; 10 | 11 | @Component 12 | public class MailService { 13 | @Autowired 14 | JavaMailSender javaMailSender; 15 | 16 | public void sendHtmlMail(String from, String to, 17 | String subject, String content){ 18 | try { 19 | MimeMessage message = javaMailSender.createMimeMessage(); 20 | MimeMessageHelper helper = new MimeMessageHelper(message, true); 21 | helper.setTo(to); 22 | helper.setFrom(from); 23 | helper.setSubject(subject); 24 | helper.setText(content, true); 25 | javaMailSender.send(message); 26 | } catch (MessagingException e) { 27 | System.out.println("发送失败"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/RegChannel.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.cloud.stream.annotation.Input; 4 | import org.springframework.cloud.stream.annotation.Output; 5 | import org.springframework.messaging.MessageChannel; 6 | import org.springframework.messaging.SubscribableChannel; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/21 21:35 11 | */ 12 | public interface RegChannel { 13 | String INPUT = "reg-input-channel"; 14 | String OUTPUT = "reg-output-channel"; 15 | 16 | @Output(OUTPUT) 17 | MessageChannel output(); 18 | @Input(INPUT) 19 | SubscribableChannel input(); 20 | } 21 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/RegController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * @Author 江南一点雨 12 | * @Date 2019/5/21 21:33 13 | */ 14 | @RestController 15 | public class RegController { 16 | @Autowired 17 | RegService regService; 18 | @PostMapping("/doReg") 19 | public Map reg(String email, String phone, String password) { 20 | return regService.reg(email, phone, password); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/RegService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.integration.support.MessageBuilder; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * @Author 江南一点雨 12 | * @Date 2019/5/21 21:34 13 | */ 14 | @Service 15 | public class RegService { 16 | 17 | @Autowired 18 | RegChannel regChannel; 19 | 20 | public Map reg(String email, String phone, String password) { 21 | //数据写入数据库 22 | Map map = new HashMap<>(); 23 | map.put("email", email); 24 | map.put("phone", phone); 25 | regChannel.output().send(MessageBuilder.withPayload(map).build()); 26 | map.put("msg", "验证短信已经发送,请注意查收!"); 27 | return map; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/SendVerifyCodeService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.stream.annotation.EnableBinding; 5 | import org.springframework.cloud.stream.annotation.Input; 6 | import org.springframework.cloud.stream.annotation.StreamListener; 7 | import org.thymeleaf.TemplateEngine; 8 | import org.thymeleaf.context.Context; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @Author 江南一点雨 14 | * @Date 2019/5/22 09:34 15 | */ 16 | @EnableBinding(RegChannel.class) 17 | public class SendVerifyCodeService { 18 | @Autowired 19 | TemplateEngine templateEngine; 20 | 21 | @Autowired 22 | MailService mailService; 23 | 24 | @StreamListener(RegChannel.INPUT) 25 | public void sendVerifyCode(Map map) { 26 | //发送验证邮件和短信 27 | System.out.println("receive:" + map); 28 | Context ctx = new Context(); 29 | String email = (String) map.get("email"); 30 | ctx.setVariable("email", email); 31 | ctx.setVariable("code",(int)(Math.random()*10000)); 32 | String mail = templateEngine.process("mailtemplate.html", ctx); 33 | mailService.sendHtmlMail("1510161612@qq.com", 34 | email, 35 | "欢迎注册XXX网站", 36 | mail); 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/java/com/justdojava/streamdemo/StreamdemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class StreamdemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(StreamdemoApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.rabbitmq.password=guest 2 | spring.rabbitmq.username=guest 3 | spring.rabbitmq.host=127.0.0.1 4 | spring.rabbitmq.port=5672 5 | 6 | spring.cloud.stream.bindings.reg-input-channel.destination=javaboy-topic 7 | spring.cloud.stream.bindings.reg-output-channel.destination=javaboy-topic 8 | 9 | spring.cloud.stream.bindings.delay_msg_input.destination=delay_msg 10 | spring.cloud.stream.bindings.delay_msg_output.destination=delay_msg 11 | spring.cloud.stream.rabbit.bindings.delay_msg_output.producer.delayed-exchange=true 12 | spring.cloud.stream.rabbit.bindings.delay_msg_input.consumer.delayed-exchange=true 13 | 14 | 15 | spring.mail.host=smtp.qq.com 16 | spring.mail.port=465 17 | spring.mail.username=1510161612@qq.com 18 | spring.mail.password=igprkcldlddxiiae 19 | spring.mail.default-encoding=UTF-8 20 | spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory 21 | spring.mail.properties.mail.debug=true -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/main/resources/templates/mailtemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 注册验证 6 | 7 | 8 |
注册验证
9 |
您的注册信息是: 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
邮箱地址
验证码
20 |
21 |
22 | 如果您未注册本站,请忽略本邮件。 23 |
24 | 25 | -------------------------------------------------------------------------------- /10-2 Spring Cloud Stream 深入实践/streamdemo/src/test/java/com/justdojava/streamdemo/StreamdemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.streamdemo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class StreamdemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/12-2 Zipkin 实践/zipkin/consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/consumer/src/main/java/org/justdojava/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package org.justdojava.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @SpringBootApplication 9 | public class ConsumerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConsumerApplication.class, args); 13 | } 14 | 15 | @Bean 16 | RestTemplate restTemplate() { 17 | return new RestTemplate(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/consumer/src/main/java/org/justdojava/consumer/UseHelloController.java: -------------------------------------------------------------------------------- 1 | package org.justdojava.consumer; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/26 21:10 11 | */ 12 | @RestController 13 | public class UseHelloController { 14 | @Autowired 15 | RestTemplate restTemplate; 16 | @GetMapping("/sayhello") 17 | public void hello() { 18 | String s = restTemplate.getForObject("http://localhost:8080/hello?name={1}", String.class, "javaboy"); 19 | System.out.println(s); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | spring.sleuth.web.client.enabled=true 3 | spring.sleuth.sampler.probability=1 4 | spring.zipkin.base-url=http://localhost:9411 5 | spring.zipkin.enabled=true 6 | spring.zipkin.sender.type=rabbit 7 | spring.rabbitmq.addresses=localhost 8 | spring.rabbitmq.port=5672 9 | spring.rabbitmq.username=guest 10 | spring.rabbitmq.password=guest 11 | server.port=8081 -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/consumer/src/test/java/org/justdojava/consumer/ConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.justdojava.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.justdojava 8 | zipkin 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/12-2 Zipkin 实践/zipkin/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/provider/src/main/java/org/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package org.justdojava.provider; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019/5/26 21:00 9 | */ 10 | @RestController 11 | public class HelloController { 12 | @GetMapping("/hello") 13 | public String hello(String name) { 14 | return "hello " + name + " !"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/provider/src/main/java/org/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package org.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | spring.sleuth.web.client.enabled=true 3 | spring.sleuth.sampler.probability=1 4 | spring.zipkin.base-url=http://localhost:9411 5 | spring.zipkin.enabled=true 6 | spring.zipkin.sender.type=rabbit 7 | spring.rabbitmq.addresses=localhost 8 | spring.rabbitmq.port=5672 9 | spring.rabbitmq.username=guest 10 | spring.rabbitmq.password=guest 11 | server.port=8080 -------------------------------------------------------------------------------- /12-2 Zipkin 实践/zipkin/provider/src/test/java/org/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminclient/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/13-1 Spring Boot Admin 介绍/monitor/adminclient/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminclient/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminclient/src/main/java/com/justdojava/adminclient/AdminclientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminclient; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AdminclientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AdminclientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminclient/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | spring.boot.admin.client.url=http://localhost:8080 3 | 4 | management.endpoints.web.exposure.include=* -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminclient/src/test/java/com/justdojava/adminclient/AdminclientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminclient; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class AdminclientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminserver/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/13-1 Spring Boot Admin 介绍/monitor/adminserver/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminserver/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminserver/src/main/java/com/justdojava/adminserver/AdminserverApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminserver; 2 | 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableAdminServer 9 | public class AdminserverApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(AdminserverApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminserver/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/adminserver/src/test/java/com/justdojava/adminserver/AdminserverApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminserver; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class AdminserverApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /13-1 Spring Boot Admin 介绍/monitor/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | monitor 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminclient/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/13-2 Spring Boot Admin 实践/monitor/adminclient/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminclient/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminclient/src/main/java/com/justdojava/adminclient/AdminclientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminclient; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AdminclientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AdminclientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminclient/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=adminclient 2 | server.port=8081 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka/ 4 | management.endpoints.web.exposure.include=* -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminclient/src/test/java/com/justdojava/adminclient/AdminclientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminclient; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class AdminclientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminserver/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/13-2 Spring Boot Admin 实践/monitor/adminserver/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminserver/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminserver/src/main/java/com/justdojava/adminserver/AdminserverApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminserver; 2 | 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableAdminServer 9 | public class AdminserverApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(AdminserverApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminserver/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=adminserver 2 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka 3 | management.endpoints.web.exposure.include=* 4 | spring.mail.host=smtp.qq.com 5 | spring.mail.port=465 6 | spring.mail.username=xxx@qq.com 7 | spring.mail.password=xxx 8 | spring.mail.default-encoding=UTF-8 9 | spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory 10 | spring.mail.properties.mail.debug=true 11 | spring.boot.admin.notify.mail.from=xxx@qq.com 12 | spring.boot.admin.notify.mail.to=xxx@qq.com 13 | spring.boot.admin.notify.mail.cc=xxx@qq.com 14 | spring.boot.admin.notify.mail.ignore-changes= -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/adminserver/src/test/java/com/justdojava/adminserver/AdminserverApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.adminserver; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class AdminserverApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/13-2 Spring Boot Admin 实践/monitor/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=1111 2 | eureka.client.register-with-eureka=false 3 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /13-2 Spring Boot Admin 实践/monitor/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | monitor 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.justdojava 12 | nacos-client 13 | 0.0.1-SNAPSHOT 14 | nacos-client 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-alibaba-nacos-discovery 29 | 0.9.0.RELEASE 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos-client/src/main/java/com/justdojava/nacosclient/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.nacosclient; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/6/7 22:52 11 | */ 12 | @RestController 13 | public class HelloController { 14 | @Autowired 15 | RestTemplate restTemplate; 16 | @GetMapping("/hello") 17 | public String hello() { 18 | return restTemplate.getForObject("http://nacos/hello", String.class); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos-client/src/main/java/com/justdojava/nacosclient/NacosClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.nacosclient; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @SpringBootApplication 10 | public class NacosClientApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(NacosClientApplication.class, args); 14 | } 15 | 16 | @Bean 17 | @LoadBalanced 18 | RestTemplate restTemplate() { 19 | return new RestTemplate(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 2 | server.port=8082 -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos-client/src/test/java/com/justdojava/nacosclient/NacosClientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.nacosclient; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class NacosClientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos/src/main/java/com/justdojava/nacos/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.nacos; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.cloud.context.config.annotation.RefreshScope; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/6/7 20:28 11 | */ 12 | @RestController 13 | @RefreshScope 14 | public class HelloController { 15 | @Value(value = "${name}") 16 | String name; 17 | @Value("${server.port}") 18 | Integer port; 19 | 20 | @GetMapping("/hello") 21 | public String hello() { 22 | return "hello " + name + ">>>" + port; 23 | } 24 | } -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos/src/main/java/com/justdojava/nacos/NacosApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.nacos; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class NacosApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(NacosApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/14-2 Nacos 基础用法/nacos/src/main/resources/application.properties -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=nacos 2 | spring.cloud.nacos.config.server-addr=127.0.0.1:8848 3 | spring.cloud.nacos.config.file-extension=properties 4 | spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 5 | server.port=8083 -------------------------------------------------------------------------------- /14-2 Nacos 基础用法/nacos/src/test/java/com/justdojava/nacos/NacosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.nacos; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class NacosApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /14-3 Sentinel 基本用法/sentinel/src/main/java/com/justdojava/sentinel/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.sentinel; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019/6/8 13:25 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @GetMapping("/hello") 14 | public String hello() { 15 | return "hello spring boot!"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /14-3 Sentinel 基本用法/sentinel/src/main/java/com/justdojava/sentinel/SentinelApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.sentinel; 2 | 3 | import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.alibaba.sentinel.annotation.SentinelRestTemplate; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | @SpringBootApplication 11 | public class SentinelApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SentinelApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /14-3 Sentinel 基本用法/sentinel/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.sentinel.transport.dashboard=localhost:8080 2 | spring.application.name=sentinel 3 | server.port=8081 4 | 5 | spring.cloud.sentinel.datasource.ds.nacos.server-addr=localhost:8848 6 | spring.cloud.sentinel.datasource.ds.nacos.dataId=sentinel-rule 7 | spring.cloud.sentinel.datasource.ds.nacos.groupId=DEFAULT_GROUP 8 | spring.cloud.sentinel.datasource.ds.nacos.rule-type=flow -------------------------------------------------------------------------------- /14-3 Sentinel 基本用法/sentinel/src/test/java/com/justdojava/sentinel/SentinelApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.sentinel; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | import java.util.Date; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest 14 | public class SentinelApplicationTests { 15 | 16 | @Test 17 | public void contextLoads() { 18 | RestTemplate restTemplate = new RestTemplate(); 19 | for (int i = 0; i < 15; i++) { 20 | String s = restTemplate.getForObject("http://localhost:8081/hello", String.class); 21 | System.out.println(i + ":" + s+":"+new Date()); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/2-3 Spring Boot 的设计理念和简单实践/hello/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.3.RELEASE 9 | 10 | 11 | com.justdojava 12 | hello 13 | 0.0.1-SNAPSHOT 14 | hello 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/src/main/java/com/justdojava/hello/HelloApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HelloApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(HelloApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/src/main/java/com/justdojava/hello/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hello; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | return "hello world"; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /2-3 Spring Boot 的设计理念和简单实践/hello/src/test/java/com/justdojava/hello/HelloApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.hello; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class HelloApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-a/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-a/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-a/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-a/src/main/java/com/justdojava/eureka/EurekaAApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaAApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaAApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-a/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka server 2 | server.port=8001 3 | 4 | eureka.instance.hostname=eurekaA 5 | eureka.client.serviceUrl.defaultZone=http://eurekaB:8002/eureka/,http://eurekaC:8003/eureka/ 6 | 7 | eureka.client.register-with-eureka=true 8 | eureka.client.fetch-registry=true -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-b/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-b/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-b/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-b/src/main/java/com/justdojava/eureka/EurekaBApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaBApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaBApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-b/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka server 2 | server.port=8002 3 | 4 | eureka.instance.hostname=eurekaB 5 | eureka.client.serviceUrl.defaultZone=http://eurekaA:8001/eureka/,http://eurekaC:8003/eureka/ 6 | 7 | eureka.client.register-with-eureka=true 8 | eureka.client.fetch-registry=true -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-c/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-c/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-c/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-c/src/main/java/com/justdojava/eureka/EurekaCApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaCApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaCApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/eureka-c/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka server 2 | server.port=8003 3 | 4 | eureka.instance.hostname=eurekaC 5 | eureka.client.serviceUrl.defaultZone=http://eurekaA:8001/eureka/,http://eurekaB:8002/eureka/ 6 | 7 | eureka.client.register-with-eureka=true 8 | eureka.client.fetch-registry=true -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka-cluster/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.justdojava 7 | spring-cloud-eureka 8 | 1.0.0 9 | 10 | 11 | eureka-a 12 | eureka-b 13 | eureka-c 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-1 Eureka 服务注册中心的搭建/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.3.RELEASE 9 | 10 | 11 | com.justdojava 12 | eureka 13 | 0.0.1-SNAPSHOT 14 | eureka 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | Greenwich.SR1 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-dependencies 34 | ${spring-cloud.version} 35 | pom 36 | import 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-1 Eureka 服务注册中心的搭建/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka server 2 | server.port=8000 3 | 4 | eureka.client.register-with-eureka=false 5 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-5 Consul 架构原理和实践/consul/consul-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-consumer/src/main/java/com/justdojava/consul/ConsulConsummerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consul; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class ConsulConsummerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConsulConsummerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-consumer/src/main/java/com/justdojava/consul/controller/CallHelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consul.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.client.ServiceInstance; 5 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | @RestController 11 | public class CallHelloController { 12 | 13 | @Autowired 14 | private LoadBalancerClient loadBalancer; 15 | 16 | @RequestMapping("/call") 17 | public String call() { 18 | ServiceInstance serviceInstance = loadBalancer.choose("service-producer"); 19 | System.out.println("服务地址:" + serviceInstance.getUri()); 20 | System.out.println("服务名称:" + serviceInstance.getServiceId()); 21 | 22 | String callServiceResult = new RestTemplate().getForObject(serviceInstance.getUri().toString() + "/hello", String.class); 23 | System.out.println(callServiceResult); 24 | return callServiceResult; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-5 Consul 架构原理和实践/consul/consul-consumer/src/main/resources/application.properties -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider-2/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-5 Consul 架构原理和实践/consul/consul-provider-2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider-2/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider-2/src/main/java/com/justdojava/consul/ConsulProviderTwoApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consul; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class ConsulProviderTwoApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConsulProviderTwoApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider-2/src/main/java/com/justdojava/consul/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consul.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | return "hello consul two"; 12 | } 13 | } -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-5 Consul 架构原理和实践/consul/consul-provider-2/src/main/resources/application.properties -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-5 Consul 架构原理和实践/consul/consul-provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider/src/main/java/com/justdojava/consul/ConsulProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consul; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class ConsulProviderApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConsulProviderApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider/src/main/java/com/justdojava/consul/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consul.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | return "hello consul"; 12 | } 13 | } -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/consul-provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/3-5 Consul 架构原理和实践/consul/consul-provider/src/main/resources/application.properties -------------------------------------------------------------------------------- /3-5 Consul 架构原理和实践/consul/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.justdojava 7 | spring-cloud-consul 8 | 1.0.0 9 | 10 | 11 | consul-provider 12 | consul-provider-2 13 | consul-consumer 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-1 服务注册与消费/ServiceRegistry/consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/consumer/src/main/java/com/justdojava/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @SpringBootApplication 10 | public class ConsumerApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(ConsumerApplication.class, args); 14 | } 15 | 16 | @Bean 17 | RestTemplate restTemplate() { 18 | return new RestTemplate(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/consumer/src/main/java/com/justdojava/consumer/UseHelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import com.netflix.discovery.converters.Auto; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.cloud.client.ServiceInstance; 6 | import org.springframework.cloud.client.discovery.DiscoveryClient; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | import java.net.URI; 12 | import java.util.List; 13 | 14 | @RestController 15 | public class UseHelloController { 16 | @Autowired 17 | DiscoveryClient discoveryClient; 18 | @Autowired 19 | RestTemplate restTemplate; 20 | 21 | @GetMapping("/hello") 22 | public String hello(String name) { 23 | List list = discoveryClient.getInstances("provider"); 24 | ServiceInstance instance = list.get(0); 25 | String host = instance.getHost(); 26 | int port = instance.getPort(); 27 | String s = restTemplate.getForObject("http://" + host + ":" + port + "/hello?name={1}", String.class, name); 28 | return s; 29 | } 30 | } -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=consumer 2 | server.port=4002 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/consumer/src/test/java/com/justdojava/consumer/ConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-1 服务注册与消费/ServiceRegistry/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | ServiceRegistry 9 | 1.0-SNAPSHOT 10 | 11 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-1 服务注册与消费/ServiceRegistry/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/provider/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | @GetMapping("/hello") 9 | public String hello(String name) { 10 | return "hello " + name + " !"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/provider/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=4001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka 4 | -------------------------------------------------------------------------------- /4-1 服务注册与消费/ServiceRegistry/provider/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4-2chapter 7 | com.justdojava 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | commons 13 | 14 | 15 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/commons/src/main/java/com/justdojava/commons/User.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.commons; 2 | 3 | import java.io.PipedReader; 4 | 5 | public class User { 6 | private String username; 7 | private String address; 8 | //省略getter/setter 9 | 10 | 11 | @Override 12 | public String toString() { 13 | return "User{" + 14 | "username='" + username + '\'' + 15 | ", address='" + address + '\'' + 16 | '}'; 17 | } 18 | 19 | public String getUsername() { 20 | return username; 21 | } 22 | 23 | public void setUsername(String username) { 24 | this.username = username; 25 | } 26 | 27 | public String getAddress() { 28 | return address; 29 | } 30 | 31 | public void setAddress(String address) { 32 | this.address = address; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-2 RestTemplate 使用详解/RestTemplate/consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/consumer/src/main/java/com/justdojava/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @SpringBootApplication 10 | public class ConsumerApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(ConsumerApplication.class, args); 14 | } 15 | 16 | @Bean 17 | RestTemplate restTemplate() { 18 | return new RestTemplate(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=consumer 2 | server.port=4002 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/consumer/src/test/java/com/justdojava/consumer/ConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-2 RestTemplate 使用详解/RestTemplate/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | RestTemplate 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | commons 13 | 14 | 15 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-2 RestTemplate 使用详解/RestTemplate/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | @RestController 10 | public class HelloController { 11 | @GetMapping("/hello") 12 | public String sayHello(String name) { 13 | return "hello " + name + " !"; 14 | } 15 | 16 | @PostMapping("/hello2") 17 | public String sayHello2(String name) { 18 | return "Hello " + name + " !"; 19 | } 20 | 21 | @GetMapping("/customheader") 22 | public String customHeader(HttpServletRequest req) { 23 | return req.getHeader("cookie"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/src/main/java/com/justdojava/provider/UserController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import com.justdojava.commons.User; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | import java.net.URLEncoder; 9 | 10 | @Controller 11 | public class UserController { 12 | @ResponseBody 13 | @PostMapping("/user") 14 | public User hello(@RequestBody User user) { 15 | return user; 16 | } 17 | 18 | @RequestMapping("/register") 19 | public String register(User user) throws UnsupportedEncodingException { 20 | return "redirect:/loginPage?username=" + URLEncoder.encode(user.getUsername(),"UTF-8") + "&address=" + URLEncoder.encode(user.getAddress(),"UTF-8"); 21 | } 22 | 23 | @GetMapping("/loginPage") 24 | @ResponseBody 25 | public String loginPage(User user) { 26 | return "loginPage:" + user.getUsername() + ":" + user.getAddress(); 27 | } 28 | 29 | 30 | @PutMapping("/user/name") 31 | @ResponseBody 32 | public void updateUserByUsername(User User) { 33 | System.out.println(User); 34 | } 35 | 36 | @PutMapping("/user/address") 37 | @ResponseBody 38 | public void updateUserByAddress(@RequestBody User User) { 39 | System.out.println(User); 40 | } 41 | 42 | @DeleteMapping("/user/{id}") 43 | @ResponseBody 44 | public void deleteUserById(@PathVariable Integer id) { 45 | System.out.println(id); 46 | } 47 | 48 | @DeleteMapping("/user/") 49 | @ResponseBody 50 | public void deleteUserByUsername(String username) { 51 | System.out.println(username); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=4001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka 4 | -------------------------------------------------------------------------------- /4-2 RestTemplate 使用详解/RestTemplate/provider/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-3 服务请求负载均衡/Loadbalancer/consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/consumer/src/main/java/com/justdojava/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import com.netflix.loadbalancer.IRule; 4 | import com.netflix.loadbalancer.RandomRule; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.http.HttpRequest; 10 | import org.springframework.http.client.ClientHttpRequestExecution; 11 | import org.springframework.http.client.ClientHttpRequestInterceptor; 12 | import org.springframework.http.client.ClientHttpResponse; 13 | import org.springframework.web.client.RestTemplate; 14 | 15 | import java.io.IOException; 16 | 17 | @SpringBootApplication 18 | public class ConsumerApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(ConsumerApplication.class, args); 22 | } 23 | 24 | @Bean 25 | RestTemplate restTemplate() { 26 | return new RestTemplate(); 27 | } 28 | @Bean 29 | @LoadBalanced 30 | RestTemplate loadBalancer() { 31 | RestTemplate loadBalancer = new RestTemplate(); 32 | return loadBalancer; 33 | } 34 | @Bean 35 | IRule iRule() { 36 | return new RandomRule(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-3 服务请求负载均衡/Loadbalancer/consumer/src/main/resources/application.properties -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/consumer/src/test/java/com/justdojava/consumer/ConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-3 服务请求负载均衡/Loadbalancer/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | Loadbalancer 9 | 1.0-SNAPSHOT 10 | 11 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/4-3 服务请求负载均衡/Loadbalancer/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/provider/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019-03-25 20:17 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @Value("${server.port}") 14 | Integer port; 15 | 16 | @GetMapping("/hello") 17 | public String hello(String name) { 18 | return "hello " + name + " ; " + port; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/provider/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=4001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /4-3 服务请求负载均衡/Loadbalancer/provider/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Feign 7 | com.justdojava 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | commons 13 | 14 | 15 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/commons/src/main/java/com/justdojava/commons/User.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.commons; 2 | 3 | /** 4 | * @Author 江南一点雨 5 | * @Date 2019-03-29 21:12 6 | */ 7 | public class User { 8 | private Long id; 9 | private String username; 10 | private String address; 11 | //省略getter/setter 12 | 13 | 14 | @Override 15 | public String toString() { 16 | return "User{" + 17 | "id=" + id + 18 | ", username='" + username + '\'' + 19 | ", address='" + address + '\'' + 20 | '}'; 21 | } 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getUsername() { 32 | return username; 33 | } 34 | 35 | public void setUsername(String username) { 36 | this.username = username; 37 | } 38 | 39 | public String getAddress() { 40 | return address; 41 | } 42 | 43 | public void setAddress(String address) { 44 | this.address = address; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-1 声明式服务调用 Feign/Feign/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-1 声明式服务调用 Feign/Feign/feign-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/src/main/java/com/justdojava/feignconsumer/FeignConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | @SpringBootApplication 8 | @EnableFeignClients 9 | public class FeignConsumerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(FeignConsumerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/src/main/java/com/justdojava/feignconsumer/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import com.justdojava.commons.User; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019-03-28 21:10 11 | */ 12 | @RestController 13 | public class HelloController { 14 | @Autowired 15 | HelloService helloService; 16 | 17 | @GetMapping("/hello") 18 | public String hello(String name) { 19 | return helloService.hello(name); 20 | } 21 | 22 | @GetMapping("/hello2") 23 | public void hello2() { 24 | helloService.deleteUserById(99L); 25 | User u2 = helloService.getUserByName("纯洁的微笑"); 26 | System.out.println(u2); 27 | u2.setId(98L); 28 | u2.setAddress("深圳"); 29 | User u3 = helloService.addUser(u2); 30 | System.out.println(u3); 31 | helloService.updateUserById("lenve", 99L); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/src/main/java/com/justdojava/feignconsumer/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import com.justdojava.commons.User; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019-03-28 21:09 10 | */ 11 | @FeignClient("provider") 12 | public interface HelloService { 13 | @GetMapping("/hello") 14 | String hello(@RequestParam("name") String name); 15 | @DeleteMapping("/user/{id}") 16 | void deleteUserById(@PathVariable("id") Long id); 17 | 18 | @GetMapping("/user") 19 | User getUserByName(@RequestParam("name") String name); 20 | 21 | @PostMapping("/user") 22 | User addUser(@RequestBody User user); 23 | 24 | @PutMapping("/user") 25 | void updateUserById(@RequestHeader("name") String name, @RequestHeader("id") Long id); 26 | } 27 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=feign-consumer 2 | server.port=5002 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/feign-consumer/src/test/java/com/justdojava/feignconsumer/FeignConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class FeignConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | Feign 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | commons 13 | 14 | 15 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-1 声明式服务调用 Feign/Feign/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019-03-25 20:17 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @GetMapping("/hello") 14 | public String hello(String name) { 15 | return "hello " + name + " !"; 16 | } 17 | } -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/src/main/java/com/justdojava/provider/UserController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import com.justdojava.commons.User; 4 | import org.springframework.web.bind.annotation.*; 5 | 6 | import java.net.URLDecoder; 7 | import java.net.URLEncoder; 8 | 9 | /** 10 | * @Author 江南一点雨 11 | * @Date 2019-03-29 21:08 12 | */ 13 | @RestController 14 | public class UserController { 15 | 16 | @DeleteMapping("/user/{id}") 17 | public void deleteUserById(@PathVariable Long id) { 18 | System.out.println(id); 19 | } 20 | 21 | @GetMapping("/user") 22 | public User getUserByName(@RequestParam String name) { 23 | User user = new User(); 24 | user.setUsername(name); 25 | return user; 26 | } 27 | 28 | @PostMapping("/user") 29 | public User addUser(@RequestBody User user) { 30 | return user; 31 | } 32 | 33 | @PutMapping("/user") 34 | public void updateUserById(@RequestHeader String name, @RequestHeader Long id) { 35 | System.out.println("name:" + name + ";id:" + id); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=5001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /5-1 声明式服务调用 Feign/Feign/provider/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | FeignAdvanced 7 | com.justdojava 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | commons 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-web 18 | 2.1.3.RELEASE 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/commons/src/main/java/com/justdojava/commons/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.commons; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestParam; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019-03-31 21:10 9 | */ 10 | public interface HelloService { 11 | @GetMapping("/hello") 12 | String hello(@RequestParam("name") String name); 13 | } 14 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/src/main/java/com/justdojava/feignconsumer/FeignConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import feign.Logger; 4 | import feign.Retryer; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.logging.LogLevel; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | import org.springframework.context.annotation.Bean; 10 | 11 | @SpringBootApplication 12 | @EnableFeignClients 13 | public class FeignConsumerApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(FeignConsumerApplication.class, args); 17 | } 18 | 19 | @Bean 20 | Logger.Level loggerLevel() { 21 | return Logger.Level.FULL; 22 | } 23 | 24 | @Bean 25 | public Retryer feignRetryer() { 26 | Retryer.Default retryer = new Retryer.Default(); 27 | return retryer; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/src/main/java/com/justdojava/feignconsumer/FeignHelloService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import com.justdojava.commons.HelloService; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019-03-31 21:52 9 | */ 10 | @FeignClient("PROVIDER") 11 | public interface FeignHelloService extends HelloService { 12 | } 13 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/src/main/java/com/justdojava/feignconsumer/UseHelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019-03-31 21:59 10 | */ 11 | @RestController 12 | public class UseHelloController { 13 | @Autowired 14 | FeignHelloService feignHelloService; 15 | @GetMapping("/hello") 16 | public String hello(String name) { 17 | return feignHelloService.hello(name); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/src/main/resources/application.properties -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/feign-consumer/src/test/java/com/justdojava/feignconsumer/FeignConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.feignconsumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class FeignConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | FeignAdvanced 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | commons 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import com.justdojava.commons.HelloService; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019-03-31 21:31 9 | */ 10 | @RestController 11 | public class HelloController implements HelloService { 12 | @Override 13 | public String hello(String name) { 14 | System.out.println(">>>>>>>>>>>>"); 15 | // int i = 1 / 0; 16 | try { 17 | Thread.sleep(5*1000); 18 | } catch (InterruptedException e) { 19 | e.printStackTrace(); 20 | } 21 | return "hello " + name + " !"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=5001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /5-2 Feign 中的继承、日志与数据压缩/FeignAdvanced/provider/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /6-1 Resilience4j 基本用法详解/Resilience4j/src/test/java/com/justdojava/resilience4j/CacheTest.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.resilience4j; 2 | 3 | import io.github.resilience4j.cache.Cache; 4 | import io.vavr.CheckedFunction1; 5 | import io.vavr.control.Try; 6 | import org.junit.Test; 7 | 8 | import javax.cache.Caching; 9 | 10 | public class CacheTest { 11 | @Test 12 | public void test1() { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /6-1 Resilience4j 基本用法详解/Resilience4j/src/test/java/com/justdojava/resilience4j/RetryTest.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.resilience4j; 2 | 3 | import io.github.resilience4j.retry.Retry; 4 | import io.github.resilience4j.retry.RetryConfig; 5 | import io.vavr.CheckedFunction0; 6 | import io.vavr.control.Try; 7 | import org.junit.Test; 8 | 9 | import java.time.Duration; 10 | import java.util.Date; 11 | 12 | public class RetryTest { 13 | @Test 14 | public void test1() { 15 | RetryConfig config = RetryConfig.custom() 16 | .maxAttempts(3) 17 | .waitDuration(Duration.ofMillis(1000)) 18 | .build(); 19 | Retry retry = Retry.of("id", config); 20 | 21 | CheckedFunction0 retryableSupplier = Retry.decorateCheckedSupplier(retry, ()->{ 22 | System.out.println(new Date()); 23 | int i = 1 / 0; 24 | return "hello retry"; 25 | }); 26 | Try result = Try.of(retryableSupplier).recover((throwable) -> "Hello world from recovery function"); 27 | System.out.println(result.isSuccess()); 28 | System.out.println(result.get()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /6-1 Resilience4j 基本用法详解/Resilience4j/src/test/java/com/justdojava/resilience4j/TimeLimiterTest.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.resilience4j; 2 | 3 | import io.github.resilience4j.timelimiter.TimeLimiter; 4 | import io.github.resilience4j.timelimiter.TimeLimiterConfig; 5 | import io.vavr.control.Try; 6 | import org.junit.Test; 7 | 8 | import java.time.Duration; 9 | import java.util.concurrent.Callable; 10 | import java.util.concurrent.ExecutorService; 11 | import java.util.concurrent.Executors; 12 | import java.util.concurrent.Future; 13 | import java.util.function.Supplier; 14 | 15 | public class TimeLimiterTest { 16 | @Test 17 | public void test1() throws Exception { 18 | TimeLimiterConfig config = TimeLimiterConfig.custom() 19 | .timeoutDuration(Duration.ofSeconds(60)) 20 | .cancelRunningFuture(true) 21 | .build(); 22 | TimeLimiter timeLimiter = TimeLimiter.of(config); 23 | ExecutorService executorService = Executors.newSingleThreadExecutor(); 24 | Supplier> futureSupplier = () -> executorService.submit(backendService::doSomething); 25 | Callable restrictedCall = TimeLimiter 26 | .decorateFutureSupplier(timeLimiter, futureSupplier); 27 | Try.of(restrictedCall.call) 28 | .onFailure(throwable -> System.out.println(throwable.getMessage())); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/java/com/justdojava/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @SpringBootApplication 10 | public class ConsumerApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(ConsumerApplication.class, args); 14 | } 15 | 16 | @Bean 17 | @LoadBalanced 18 | RestTemplate restTemplate() { 19 | return new RestTemplate(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/java/com/justdojava/consumer/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; 4 | import io.github.resilience4j.retry.annotation.Retry; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | /** 10 | * @Author 江南一点雨 11 | * @Date 2019/4/8 20:08 12 | */ 13 | @Service 14 | @Retry(name = "retryBackendA") 15 | public class HelloService { 16 | @Autowired 17 | RestTemplate restTemplate; 18 | 19 | public String hello(String name) { 20 | return restTemplate.getForObject("http://provider/hello?name={1}", String.class, name); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/java/com/justdojava/consumer/IgnoredException.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | /** 4 | * @Author 江南一点雨 5 | * @Date 2019-04-10 11:08 6 | */ 7 | public class IgnoredException extends Exception { 8 | } 9 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/java/com/justdojava/consumer/RecordFailurePredicate.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** 6 | * @Author 江南一点雨 7 | * @Date 2019-04-10 11:06 8 | */ 9 | public class RecordFailurePredicate implements Predicate { 10 | @Override 11 | public boolean test(Throwable throwable) { 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/resources/application-circuitbreaker.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: consumer 4 | server: 5 | port: 6999 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://localhost:1111/eureka 10 | #resilience4j.circuitbreaker: 11 | # backends: 12 | # backendA: 13 | # ringBufferSizeInClosedState: 5 14 | # ringBufferSizeInHalfOpenState: 3 15 | # waitInterval: 5000 16 | # failureRateThreshold: 50 17 | # eventConsumerBufferSize: 10 18 | # registerHealthIndicator: true 19 | # recordFailurePredicate: com.justdojava.consumer.RecordFailurePredicate 20 | # recordExceptions: 21 | # - org.springframework.web.client.HttpServerErrorException 22 | # ignoreExceptions: 23 | # - org.springframework.web.client.HttpClientErrorException -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/resources/application-retry.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: consumer 4 | server: 5 | port: 6999 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://localhost:1111/eureka 10 | resilience4j.retry: 11 | retryAspectOrder: 399 12 | backends: 13 | retryBackendA: 14 | maxRetryAttempts: 3 15 | waitDuration: 1000 16 | eventConsumerBufferSize: 1 17 | enableExponentialBackoff: true 18 | exponentialBackoffMultiplier: 5 19 | enableRandomizedWait: false 20 | randomizedWaitFactor: 2 21 | retryExceptionPredicate: com.justdojava.consumer.RecordFailurePredicate 22 | retryExceptions: 23 | - java.io.IOException 24 | ignoreExceptions: 25 | - com.justdojava.consumer.IgnoredException -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: consumer 4 | server: 5 | port: 6999 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://localhost:1111/eureka 10 | resilience4j.ratelimiter: 11 | limiters: 12 | backendA: 13 | limitForPeriod: 1 14 | limitRefreshPeriodInMillis: 5000 15 | timeoutInMillis: 5000 16 | subscribeForEvents: true 17 | registerHealthIndicator: true 18 | eventConsumerBufferSize: 100 -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/consumer/src/test/java/com/justdojava/consumer/ConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/target/classes/com/justdojava/eureka/EurekaApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/target/classes/com/justdojava/eureka/EurekaApplication.class -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/target/test-classes/com/justdojava/eureka/EurekaApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/eureka/target/test-classes/com/justdojava/eureka/EurekaApplicationTests.class -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | Resilience4j-SpringBoot 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | import java.time.Duration; 7 | import java.util.Date; 8 | 9 | /** 10 | * @Author 江南一点雨 11 | * @Date 2019/4/8 20:00 12 | */ 13 | @RestController 14 | public class HelloController { 15 | @GetMapping("/hello") 16 | public String hello(String name) throws InterruptedException { 17 | String s = "hello " + name + " !"; 18 | System.out.println(s+">>>>>"+new Date()); 19 | return s; 20 | } 21 | } -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=6001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=6001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/classes/com/justdojava/provider/HelloController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/classes/com/justdojava/provider/HelloController.class -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/classes/com/justdojava/provider/ProviderApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/classes/com/justdojava/provider/ProviderApplication.class -------------------------------------------------------------------------------- /6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/test-classes/com/justdojava/provider/ProviderApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-2 Resilience4j 在微服务中的应用/Resilience4j-SpringBoot/provider/target/test-classes/com/justdojava/provider/ProviderApplicationTests.class -------------------------------------------------------------------------------- /6-3 Micrometer 实现微服务监控/micrometer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/6-3 Micrometer 实现微服务监控/micrometer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /6-3 Micrometer 实现微服务监控/micrometer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /6-3 Micrometer 实现微服务监控/micrometer/src/main/java/com/justdojava/micrometer/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.micrometer; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019-04-17 22:43 9 | */ 10 | @RestController 11 | public class HelloController { 12 | @GetMapping("/hello") 13 | public String hello() { 14 | return "hello"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /6-3 Micrometer 实现微服务监控/micrometer/src/main/java/com/justdojava/micrometer/MicrometerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.micrometer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MicrometerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MicrometerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /6-3 Micrometer 实现微服务监控/micrometer/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | management: 2 | metrics: 3 | export: 4 | prometheus: 5 | enabled: true 6 | endpoints: 7 | web: 8 | exposure: 9 | include: "*" 10 | endpoint: 11 | prometheus: 12 | enabled: true 13 | metrics: 14 | enabled: true -------------------------------------------------------------------------------- /6-3 Micrometer 实现微服务监控/micrometer/src/test/java/com/justdojava/micrometer/MicrometerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.micrometer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class MicrometerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/src/main/java/com/justdojava/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import com.netflix.loadbalancer.IRule; 4 | import com.netflix.loadbalancer.RandomRule; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.http.HttpRequest; 10 | import org.springframework.http.client.ClientHttpRequestExecution; 11 | import org.springframework.http.client.ClientHttpRequestInterceptor; 12 | import org.springframework.http.client.ClientHttpResponse; 13 | import org.springframework.web.client.RestTemplate; 14 | 15 | import java.io.IOException; 16 | 17 | @SpringBootApplication 18 | public class ConsumerApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(ConsumerApplication.class, args); 22 | } 23 | 24 | @Bean 25 | RestTemplate restTemplate() { 26 | return new RestTemplate(); 27 | } 28 | @Bean 29 | @LoadBalanced 30 | RestTemplate loadBalancer() { 31 | RestTemplate loadBalancer = new RestTemplate(); 32 | return loadBalancer; 33 | } 34 | @Bean 35 | IRule iRule() { 36 | return new RandomRule(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/src/main/resources/application.properties -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/consumer/src/test/java/com/justdojava/consumer/ConsumerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConsumerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | 4 | eureka.client.register-with-eureka=false 5 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/gateway/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/gateway/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/gateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/gateway/src/main/java/com/justdojava/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class GatewayApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(GatewayApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | spring: 4 | application: 5 | name: gateway 6 | cloud: 7 | gateway: 8 | discovery: 9 | locator: 10 | enabled: true 11 | eureka: 12 | client: 13 | service-url: 14 | defaultZone: http://localhost:1111/eureka/ 15 | logging: 16 | level: 17 | org.springframework.cloud.gateway: debug -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.justdojava 7 | spring-cloud-gateway-eureka 8 | 1.0.0 9 | 10 | 11 | provider-1 12 | provider-2 13 | consumer 14 | eureka 15 | gateway 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019-03-25 20:17 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @Value("${server.port}") 14 | Integer port; 15 | 16 | @GetMapping("/hello") 17 | public String hello(String name) { 18 | return "hello " + name + " ; " + port; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=4001 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-1/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/src/main/java/com/justdojava/provider/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019-03-25 20:17 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @Value("${server.port}") 14 | Integer port; 15 | 16 | @GetMapping("/hello") 17 | public String hello(String name) { 18 | return "hello " + name + " ; " + port; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/src/main/java/com/justdojava/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProviderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProviderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=provider 2 | server.port=4002 3 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway-eureka/provider-2/src/test/java/com/justdojava/provider/ProviderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ProviderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway/src/main/java/com/justdojava/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class GatewayApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(GatewayApplication.class, args); 11 | } 12 | 13 | /* @Bean 14 | public RouteLocator customRouteLocator(RouteLocatorBuilder builder) { 15 | return builder.routes() 16 | .route("path_route", r -> r.path("/get") 17 | .uri("http://httpbin.org")) 18 | .build(); 19 | }*/ 20 | } 21 | -------------------------------------------------------------------------------- /7-2 Spring Cloud Gateway 快速实践/spring-cloud-gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | spring: 4 | cloud: 5 | gateway: 6 | routes: 7 | - id: neo_route 8 | uri: http://httpbin.org 9 | predicates: 10 | - Path=/get -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-1 初识 Spring Cloud Config/CloudConfig/config_client/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/src/main/java/com/justdojava/config_client/ConfigClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConfigClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConfigClientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/src/main/java/com/justdojava/config_client/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019/5/4 16:44 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @Value("${javaboy}") 14 | String hello; 15 | @GetMapping("/hello") 16 | public String hello() { 17 | return hello; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-1 初识 Spring Cloud Config/CloudConfig/config_client/src/main/resources/application.properties -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=client1 2 | server.port=8002 3 | spring.cloud.config.profile=dev 4 | spring.cloud.config.label=master 5 | spring.cloud.config.uri=http://localhost:8001/ -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_client/src/test/java/com/justdojava/config_client/ConfigClientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigClientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-1 初识 Spring Cloud Config/CloudConfig/config_server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_server/src/main/java/com/justdojava/config_server/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=config-server 2 | server.port=8001 3 | spring.cloud.config.server.git.uri=https://github.com/lenve/configRepo.git 4 | spring.cloud.config.server.git.search-paths={application} 5 | spring.cloud.config.server.git.username=wangsong0210@gmail.com 6 | spring.cloud.config.server.git.password= -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/config_server/src/test/java/com/justdojava/config_server/ConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/CloudConfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | CloudConfig 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/configRepo/client1/client1-dev.properties: -------------------------------------------------------------------------------- 1 | javaboy= hello dev 2 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/configRepo/client1/client1-prod.properties: -------------------------------------------------------------------------------- 1 | javaboy=prod 2 | -------------------------------------------------------------------------------- /8-1 初识 Spring Cloud Config/configRepo/client1/client1-test.properties: -------------------------------------------------------------------------------- 1 | javaboy=test -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/src/main/java/com/justdojava/config_client/ConfigClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConfigClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConfigClientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/src/main/java/com/justdojava/config_client/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019/5/4 16:44 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @Value("${javaboy}") 14 | String hello; 15 | @GetMapping("/hello") 16 | public String hello() { 17 | return hello; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/src/main/resources/application.properties -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=client1 2 | server.port=8002 3 | spring.cloud.config.profile=dev 4 | spring.cloud.config.label=master 5 | spring.cloud.config.uri=http://localhost:8001/ 6 | 7 | spring.cloud.config.username=javaboy 8 | spring.cloud.config.password=123 9 | 10 | #spring.cloud.config.token= -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_client/src/test/java/com/justdojava/config_client/ConfigClientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigClientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/src/main/java/com/justdojava/config_server/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=config-server 2 | server.port=8001 3 | spring.cloud.config.server.git.uri=https://github.com/lenve/configRepo.git 4 | spring.cloud.config.server.git.search-paths={application} 5 | spring.cloud.config.server.git.username=wangsong0210@gmail.com 6 | spring.cloud.config.server.git.password= -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | encrypt.key-store.location=config-server.keystore 2 | encrypt.key-store.alias=config-server 3 | encrypt.key-store.password=123456 4 | encrypt.key-store.secret=123456 5 | 6 | spring.security.user.name=javaboy 7 | spring.security.user.password=123 -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/src/main/resources/config-server.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/src/main/resources/config-server.keystore -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/config_server/src/test/java/com/justdojava/config_server/ConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/CloudConfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | CloudConfig 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/configRepo/client1/client1-dev.properties: -------------------------------------------------------------------------------- 1 | javaboy= {cipher}AQA6SPob4/pfR2b0yTm1deMKLUE+mw0JheRxbQMnHYy1XYmQYZgRM4+h9aesdYZ07m9E61eX/TztyP94IR2iBFWHZrH5yjloveJnM/7aFEZr5nzXqnYS3fCu5CctbxBqekrZ3W/ejHeMxDoFR2IH9fdmncoOMoSfIa/j4rts6IQmr74a24qlgej/O0LPkrHfqr9ZjnK7pUk2elF0luugmwzfvK+L8JeZWBYf2oIFlWPEPeQmPPvQIPEQ2yYKIC7ZSUacc+Hi5mEpYrpL52wzcjHJmUEZsNdFe9mmqc2xW5DabTTu1oxNygh7+HQBoDa0iAWxPnTUy/rsFutpGS/LcUNFtV1ZumBPeK4DDyrDuYc0mqQCnbe/SRedJlBSkqLb0to= -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/configRepo/client1/client1-prod.properties: -------------------------------------------------------------------------------- 1 | javaboy=prod 2 | -------------------------------------------------------------------------------- /8-2 Spring Cloud Config 中配置文件的加密与解密/configRepo/client1/client1-test.properties: -------------------------------------------------------------------------------- 1 | javaboy=test -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/src/main/java/com/justdojava/config_client/ConfigClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConfigClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConfigClientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/src/main/java/com/justdojava/config_client/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.cloud.context.config.annotation.RefreshScope; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/4 16:44 11 | */ 12 | @RestController 13 | @RefreshScope 14 | public class HelloController { 15 | @Value("${javaboy}") 16 | String hello; 17 | @GetMapping("/hello") 18 | public String hello() { 19 | return hello; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/src/main/resources/application.properties -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=client1 2 | server.port=8002 3 | spring.cloud.config.profile=dev 4 | spring.cloud.config.label=master 5 | #spring.cloud.config.uri=http://localhost:8001/ 6 | spring.cloud.config.discovery.service-id=config-server 7 | spring.cloud.config.discovery.enabled=true 8 | 9 | #spring.cloud.config.username=javaboy 10 | #spring.cloud.config.password=1234 11 | 12 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka 13 | 14 | management.endpoints.web.exposure.include=refresh 15 | 16 | spring.cloud.config.fail-fast=true 17 | 18 | # 配置重试次数,默认为6 19 | spring.cloud.config.retry.max-attempts=6 20 | # 间隔乘数,默认1.1 21 | spring.cloud.config.retry.multiplier=2 22 | # 初始重试间隔时间,默认1000ms 23 | spring.cloud.config.retry.initial-interval=1000 24 | # 最大间隔时间,默认2000ms 25 | spring.cloud.config.retry.max-interval=20000 -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_client/src/test/java/com/justdojava/config_client/ConfigClientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigClientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/src/main/java/com/justdojava/config_server/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=config-server 2 | server.port=8001 3 | spring.cloud.config.server.git.uri=https://github.com/lenve/configRepo.git 4 | spring.cloud.config.server.git.search-paths={application} 5 | spring.cloud.config.server.git.username=wangsong0210@gmail.com 6 | spring.cloud.config.server.git.password= -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | encrypt.key-store.location=config-server.keystore 2 | encrypt.key-store.alias=config-server 3 | encrypt.key-store.password=123456 4 | encrypt.key-store.secret=123456 5 | 6 | spring.security.user.name=javaboy 7 | spring.security.user.password=123 8 | 9 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/src/main/resources/config-server.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/src/main/resources/config-server.keystore -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/config_server/src/test/java/com/justdojava/config_server/ConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/eureka/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/eureka/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/eureka/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /CloudConfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | CloudConfig 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /configRepo/client1/client1-dev.properties: -------------------------------------------------------------------------------- 1 | javaboy= {cipher}AQA6SPob4/pfR2b0yTm1deMKLUE+mw0JheRxbQMnHYy1XYmQYZgRM4+h9aesdYZ07m9E61eX/TztyP94IR2iBFWHZrH5yjloveJnM/7aFEZr5nzXqnYS3fCu5CctbxBqekrZ3W/ejHeMxDoFR2IH9fdmncoOMoSfIa/j4rts6IQmr74a24qlgej/O0LPkrHfqr9ZjnK7pUk2elF0luugmwzfvK+L8JeZWBYf2oIFlWPEPeQmPPvQIPEQ2yYKIC7ZSUacc+Hi5mEpYrpL52wzcjHJmUEZsNdFe9mmqc2xW5DabTTu1oxNygh7+HQBoDa0iAWxPnTUy/rsFutpGS/LcUNFtV1ZumBPeK4DDyrDuYc0mqQCnbe/SRedJlBSkqLb0to= -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /configRepo/client1/client1-prod.properties: -------------------------------------------------------------------------------- 1 | javaboy=prod 2 | -------------------------------------------------------------------------------- /8-3 Spring Cloud Config 服务化、动态刷新与重试 /configRepo/client1/client1-test.properties: -------------------------------------------------------------------------------- 1 | javaboy=test -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_client/src/main/java/com/justdojava/config_client/ConfigClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConfigClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConfigClientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_client/src/main/java/com/justdojava/config_client/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.cloud.context.config.annotation.RefreshScope; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Author 江南一点雨 10 | * @Date 2019/5/4 16:44 11 | */ 12 | @RestController 13 | @RefreshScope 14 | public class HelloController { 15 | @Value("${javaboy}") 16 | String hello; 17 | @GetMapping("/hello") 18 | public String hello() { 19 | return hello; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_client/src/main/resources/application.properties -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_client/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=client1 2 | server.port=8002 3 | spring.cloud.config.profile=dev 4 | spring.cloud.config.label=master 5 | #spring.cloud.config.uri=http://localhost:8001/ 6 | spring.cloud.config.discovery.service-id=config-server 7 | spring.cloud.config.discovery.enabled=true 8 | 9 | spring.cloud.config.username=javaboy 10 | spring.cloud.config.password=123 11 | 12 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka 13 | 14 | management.endpoints.web.exposure.include=refresh 15 | 16 | spring.cloud.config.fail-fast=true 17 | 18 | # 配置重试次数,默认为6 19 | spring.cloud.config.retry.max-attempts=6 20 | # 间隔乘数,默认1.1 21 | spring.cloud.config.retry.multiplier=1 22 | # 初始重试间隔时间,默认1000ms 23 | spring.cloud.config.retry.initial-interval=1000 24 | # 最大间隔时间,默认2000ms 25 | spring.cloud.config.retry.max-interval=20000 26 | 27 | spring.rabbitmq.host=127.0.0.1 28 | spring.rabbitmq.port=5672 29 | spring.rabbitmq.username=guest 30 | spring.rabbitmq.password=guest 31 | 32 | eureka.instance.instance-id=${spring.application.name}:${server.port} -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_client/src/test/java/com/justdojava/config_client/ConfigClientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_client; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigClientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/main/java/com/justdojava/config_server/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/main/java/com/justdojava/config_server/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 6 | 7 | /** 8 | * @Author 江南一点雨 9 | * @Date 2019/5/15 15:05 10 | */ 11 | @Configuration 12 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 13 | @Override 14 | protected void configure(HttpSecurity http) throws Exception { 15 | http.authorizeRequests() 16 | .anyRequest().authenticated() 17 | .and() 18 | .httpBasic() 19 | .and() 20 | .csrf().disable(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=config-server 2 | server.port=8001 3 | spring.cloud.config.server.git.uri=https://github.com/lenve/configRepo.git 4 | spring.cloud.config.server.git.search-paths={application} 5 | spring.cloud.config.server.git.username=wangsong0210@gmail.com 6 | spring.cloud.config.server.git.password= -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | encrypt.key-store.location=config-server.keystore 2 | encrypt.key-store.alias=config-server 3 | encrypt.key-store.password=123456 4 | encrypt.key-store.secret=123456 5 | 6 | spring.security.user.name=javaboy 7 | spring.security.user.password=123 8 | 9 | eureka.client.service-url.defaultZone=http://localhost:1111/eureka 10 | 11 | spring.rabbitmq.host=127.0.0.1 12 | spring.rabbitmq.port=5672 13 | spring.rabbitmq.username=guest 14 | spring.rabbitmq.password=guest 15 | 16 | management.endpoints.web.exposure.include=* 17 | #management.security.enabled=false -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/main/resources/config-server.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/main/resources/config-server.keystore -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/config_server/src/test/java/com/justdojava/config_server/ConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.config_server; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ConfigServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/eureka/src/main/java/com/justdojava/eureka/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=eureka 2 | server.port=1111 3 | eureka.client.register-with-eureka=false 4 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/eureka/src/test/java/com/justdojava/eureka/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.eureka; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/CloudConfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.justdojava 8 | CloudConfig 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/configRepo/client1/client1-dev.properties: -------------------------------------------------------------------------------- 1 | javaboy= hello dev 123456! -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/configRepo/client1/client1-prod.properties: -------------------------------------------------------------------------------- 1 | javaboy=prod 2 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/configRepo/client1/client1-test.properties: -------------------------------------------------------------------------------- 1 | javaboy=test -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justdojava/spring-cloud-learning/ba1fb1c2133e55cdf09ef7272e3ac2b25d98e5e1/9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.4.RELEASE 9 | 10 | 11 | com.justdojava 12 | rabbitmq 13 | 0.0.1-SNAPSHOT 14 | rabbitmq 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-amqp 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/DirectReceiver.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019/5/15 11:38 9 | */ 10 | @Component 11 | public class DirectReceiver { 12 | @RabbitListener(queues = "hello-queue") 13 | public void handler1(String msg) { 14 | System.out.println("DirectReceiver:" + msg); 15 | } 16 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/FanoutReceiver.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019/5/15 11:43 9 | */ 10 | @Component 11 | public class FanoutReceiver { 12 | @RabbitListener(queues = "queue-one") 13 | public void handler1(String message) { 14 | System.out.println("FanoutReceiver:handler1:" + message); 15 | } 16 | @RabbitListener(queues = "queue-two") 17 | public void handler2(String message) { 18 | System.out.println("FanoutReceiver:handler2:" + message); 19 | } 20 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/HeaderReceiver.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019/5/15 12:12 9 | */ 10 | @Component 11 | public class HeaderReceiver { 12 | @RabbitListener(queues = "name-queue") 13 | public void handler1(byte[] msg) { 14 | System.out.println("HeaderReceiver:name:" 15 | + new String(msg, 0, msg.length)); 16 | } 17 | @RabbitListener(queues = "age-queue") 18 | public void handler2(byte[] msg) { 19 | System.out.println("HeaderReceiver:age:" 20 | + new String(msg, 0, msg.length)); 21 | } 22 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/RabbitDirectConfig.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.DirectExchange; 6 | import org.springframework.amqp.core.Queue; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * @Author 江南一点雨 12 | * @Date 2019/5/15 11:37 13 | */ 14 | @Configuration 15 | public class RabbitDirectConfig { 16 | public final static String DIRECTNAME = "sang-direct"; 17 | @Bean 18 | Queue queue() { 19 | return new Queue("hello-queue"); 20 | } 21 | @Bean 22 | DirectExchange directExchange() { 23 | return new DirectExchange(DIRECTNAME, true, false); 24 | } 25 | @Bean 26 | Binding binding() { 27 | return BindingBuilder.bind(queue()) 28 | .to(directExchange()).with("direct"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/RabbitFanoutConfig.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.FanoutExchange; 6 | import org.springframework.amqp.core.Queue; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * @Author 江南一点雨 12 | * @Date 2019/5/15 11:42 13 | */ 14 | @Configuration 15 | public class RabbitFanoutConfig { 16 | public final static String FANOUTNAME = "sang-fanout"; 17 | @Bean 18 | FanoutExchange fanoutExchange() { 19 | return new FanoutExchange(FANOUTNAME, true, false); 20 | } 21 | @Bean 22 | Queue queueOne() { 23 | return new Queue("queue-one"); 24 | } 25 | @Bean 26 | Queue queueTwo() { 27 | return new Queue("queue-two"); 28 | } 29 | @Bean 30 | Binding bindingOne() { 31 | return BindingBuilder.bind(queueOne()).to(fanoutExchange()); 32 | } 33 | @Bean 34 | Binding bindingTwo() { 35 | return BindingBuilder.bind(queueTwo()).to(fanoutExchange()); 36 | } 37 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/RabbitHeaderConfig.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.HeadersExchange; 6 | import org.springframework.amqp.core.Queue; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | /** 14 | * @Author 江南一点雨 15 | * @Date 2019/5/15 12:12 16 | */ 17 | @Configuration 18 | public class RabbitHeaderConfig { 19 | public final static String HEADERNAME = "sang-header"; 20 | @Bean 21 | HeadersExchange headersExchange() { 22 | return new HeadersExchange(HEADERNAME, true, false); 23 | } 24 | @Bean 25 | Queue queueName() { 26 | return new Queue("name-queue"); 27 | } 28 | @Bean 29 | Queue queueAge() { 30 | return new Queue("age-queue"); 31 | } 32 | @Bean 33 | Binding bindingName() { 34 | Map map = new HashMap<>(); 35 | map.put("name", "sang"); 36 | return BindingBuilder.bind(queueName()) 37 | .to(headersExchange()).whereAny(map).match(); 38 | } 39 | @Bean 40 | Binding bindingAge() { 41 | return BindingBuilder.bind(queueAge()) 42 | .to(headersExchange()).where("age").exists(); 43 | } 44 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/RabbitTopicConfig.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.Queue; 6 | import org.springframework.amqp.core.TopicExchange; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * @Author 江南一点雨 12 | * @Date 2019/5/15 12:03 13 | */ 14 | @Configuration 15 | public class RabbitTopicConfig { 16 | public final static String TOPICNAME = "sang-topic"; 17 | @Bean 18 | TopicExchange topicExchange() { 19 | return new TopicExchange(TOPICNAME, true, false); 20 | } 21 | @Bean 22 | Queue xiaomi() { 23 | return new Queue("xiaomi"); 24 | } 25 | @Bean 26 | Queue huawei() { 27 | return new Queue("huawei"); 28 | } 29 | @Bean 30 | Queue phone() { 31 | return new Queue("phone"); 32 | } 33 | @Bean 34 | Binding xiaomiBinding() { 35 | return BindingBuilder.bind(xiaomi()).to(topicExchange()) 36 | .with("xiaomi.#"); 37 | } 38 | @Bean 39 | Binding huaweiBinding() { 40 | return BindingBuilder.bind(huawei()).to(topicExchange()) 41 | .with("huawei.#"); 42 | } 43 | @Bean 44 | Binding phoneBinding() { 45 | return BindingBuilder.bind(phone()).to(topicExchange()) 46 | .with("#.phone.#"); 47 | } 48 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/RabbitmqApplication.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.core.Queue; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | @SpringBootApplication 9 | public class RabbitmqApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(RabbitmqApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/java/com/justdojava/rabbitmq/TopicReceiver.java: -------------------------------------------------------------------------------- 1 | package com.justdojava.rabbitmq; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Author 江南一点雨 8 | * @Date 2019/5/15 12:03 9 | */ 10 | @Component 11 | public class TopicReceiver { 12 | @RabbitListener(queues = "phone") 13 | public void handler1(String message) { 14 | System.out.println("PhoneReceiver:" + message); 15 | } 16 | @RabbitListener(queues = "xiaomi") 17 | public void handler2(String message) { 18 | System.out.println("XiaoMiReceiver:"+message); 19 | } 20 | @RabbitListener(queues = "huawei") 21 | public void handler3(String message) { 22 | System.out.println("HuaWeiReceiver:"+message); 23 | } 24 | } -------------------------------------------------------------------------------- /9-2 Spring Cloud Bus 整合 RabbitMQ 与 Kafka/rabbitmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.rabbitmq.host=127.0.0.1 2 | spring.rabbitmq.port=5672 3 | spring.rabbitmq.username=guest 4 | spring.rabbitmq.password=guest -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 慕课网专栏示例项目 --------------------------------------------------------------------------------