├── cloud-configs ├── config-client-prd.properties ├── config-client.properties ├── config-client-test.properties ├── busTest-dev.properties └── config-client-dev.properties ├── files ├── 5-6.png └── 5-7.png ├── springcloud.jpg ├── config-client ├── src │ └── main │ │ ├── resources │ │ ├── bootstrap.properties │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ └── ConfigClientApplication.java └── pom.xml ├── eureka-zuul ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── EurekaZuulApplication.java │ │ ├── controller │ │ └── HomeController.java │ │ └── filter │ │ └── DemoFilter.java └── pom.xml ├── config-server ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ └── ConfigServerApplication.java └── pom.xml ├── consul-client ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── ConsulClientApplication.java │ │ └── controller │ │ └── DemoController.java ├── .gitignore └── pom.xml ├── eureka-client ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── EurekaClientApplication.java │ │ └── controller │ │ └── DemoController.java ├── .gitignore └── pom.xml ├── eureka-server ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ └── EurekaServerApplication.java ├── .gitignore └── pom.xml ├── eureka-consumer ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── EurekaConsumerApplication.java │ │ └── controller │ │ └── ConsumerController.java ├── .gitignore └── pom.xml ├── config-eureka-client ├── src │ └── main │ │ ├── resources │ │ ├── bootstrap.properties │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ └── ConfigEurekaClientApplication.java └── pom.xml ├── config-client-eureka-bus ├── src │ └── main │ │ ├── resources │ │ ├── bootstrap.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── web │ │ └── DemoController.java │ │ └── ConfigEurekaClientBusApplication.java └── pom.xml ├── config-eureka-server ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ └── ConfigEurekaServerApplication.java └── pom.xml ├── eureka-consumer-feign ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── EurekaConsumerFeignApplication.java │ │ ├── service │ │ ├── hystrix │ │ │ └── DemoServiceHystrix.java │ │ └── DemoService.java │ │ └── controller │ │ └── ConsumerController.java ├── .gitignore └── pom.xml ├── eureka-consumer-ribbon ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── controller │ │ └── ConsumerController.java │ │ └── EurekaConsumerRibbonApplication.java ├── .gitignore └── pom.xml ├── config-server-eureka-bus ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ └── ConfigEurekaServerBusApplication.java └── pom.xml ├── eureka-consumer-ribbon-hystrix ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── org │ │ └── jon │ │ └── lv │ │ ├── controller │ │ └── ConsumerController.java │ │ ├── service │ │ └── DemoService.java │ │ └── EurekaConsumerRibbonHystrixApplication.java ├── .gitignore └── pom.xml ├── .gitignore ├── pom.xml └── README.md /cloud-configs/config-client-prd.properties: -------------------------------------------------------------------------------- 1 | #测试配置 2 | jon=hello prd!!! -------------------------------------------------------------------------------- /cloud-configs/config-client.properties: -------------------------------------------------------------------------------- 1 | #测试配置 2 | jon=hello default!!! -------------------------------------------------------------------------------- /cloud-configs/config-client-test.properties: -------------------------------------------------------------------------------- 1 | #测试配置 2 | jon=hello test!!! -------------------------------------------------------------------------------- /files/5-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/files/5-6.png -------------------------------------------------------------------------------- /files/5-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/files/5-7.png -------------------------------------------------------------------------------- /springcloud.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/springcloud.jpg -------------------------------------------------------------------------------- /cloud-configs/busTest-dev.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/cloud-configs/busTest-dev.properties -------------------------------------------------------------------------------- /cloud-configs/config-client-dev.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/cloud-configs/config-client-dev.properties -------------------------------------------------------------------------------- /config-client/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-client/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /eureka-zuul/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-zuul/src/main/resources/application.properties -------------------------------------------------------------------------------- /config-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-client/src/main/resources/application.properties -------------------------------------------------------------------------------- /config-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-server/src/main/resources/application.properties -------------------------------------------------------------------------------- /consul-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/consul-client/src/main/resources/application.properties -------------------------------------------------------------------------------- /eureka-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-client/src/main/resources/application.properties -------------------------------------------------------------------------------- /eureka-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-server/src/main/resources/application.properties -------------------------------------------------------------------------------- /eureka-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-consumer/src/main/resources/application.properties -------------------------------------------------------------------------------- /config-eureka-client/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-eureka-client/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /config-client-eureka-bus/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-client-eureka-bus/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /config-eureka-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-eureka-client/src/main/resources/application.properties -------------------------------------------------------------------------------- /config-eureka-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-eureka-server/src/main/resources/application.properties -------------------------------------------------------------------------------- /eureka-consumer-feign/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-consumer-feign/src/main/resources/application.properties -------------------------------------------------------------------------------- /eureka-consumer-ribbon/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-consumer-ribbon/src/main/resources/application.properties -------------------------------------------------------------------------------- /config-server-eureka-bus/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/config-server-eureka-bus/src/main/resources/application.properties -------------------------------------------------------------------------------- /eureka-consumer-ribbon-hystrix/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/L316476844/springcloudexample/HEAD/eureka-consumer-ribbon-hystrix/src/main/resources/application.properties -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /consul-client/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-client/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-server/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-consumer-feign/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-consumer-ribbon/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-consumer-ribbon-hystrix/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /eureka-server/src/main/java/org/jon/lv/EurekaServerApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 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 | @EnableEurekaServer 8 | @SpringBootApplication 9 | public class EurekaServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServerApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /consul-client/src/main/java/org/jon/lv/ConsulClientApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | 8 | @EnableDiscoveryClient 9 | @SpringBootApplication 10 | public class ConsulClientApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(ConsulClientApplication.class, args); 14 | } 15 | } -------------------------------------------------------------------------------- /eureka-client/src/main/java/org/jon/lv/EurekaClientApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | 8 | @EnableDiscoveryClient 9 | @SpringBootApplication 10 | public class EurekaClientApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(EurekaClientApplication.class, args); 14 | } 15 | } -------------------------------------------------------------------------------- /eureka-zuul/src/main/java/org/jon/lv/EurekaZuulApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 8 | 9 | @EnableZuulProxy 10 | @EnableDiscoveryClient 11 | @SpringBootApplication 12 | public class EurekaZuulApplication { 13 | public static void main(String[] args) { 14 | 15 | SpringApplication.run(EurekaZuulApplication.class, args); 16 | } 17 | } -------------------------------------------------------------------------------- /eureka-consumer-feign/src/main/java/org/jon/lv/EurekaConsumerFeignApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 8 | 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | @EnableFeignClients 12 | public class EurekaConsumerFeignApplication { 13 | public static void main(String[] args) { 14 | 15 | SpringApplication.run(EurekaConsumerFeignApplication.class, args); 16 | } 17 | } -------------------------------------------------------------------------------- /eureka-consumer-feign/src/main/java/org/jon/lv/service/hystrix/DemoServiceHystrix.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.service.hystrix; 2 | 3 | import org.jon.lv.service.DemoService; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Package org.jon.lv.service.hystrix.DemoServiceHystrix 8 | * @Description: DemoServiceHystrix 9 | * @Copyright: Copyright (c) 2016 10 | * Author lv bin 11 | * @date 2017/6/28 11:26 12 | * version V1.0.0 13 | */ 14 | @Component 15 | public class DemoServiceHystrix implements DemoService{ 16 | @Override 17 | public String demo() { 18 | /** 19 | * demo 接口断路时 fallback返回一个固定值 20 | */ 21 | return "sorry,net error"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /config-server/src/main/java/org/jon/lv/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | /** 8 | * @Package org.jon.lv.ConfigServerApplication 9 | * @Copyright: Copyright (c) 2016 10 | * Author lv bin 11 | * @date 2017/7/3 10:44 12 | * version V1.0.0 13 | */ 14 | 15 | @SpringBootApplication 16 | @EnableConfigServer 17 | public class ConfigServerApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(ConfigServerApplication.class, args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /eureka-zuul/src/main/java/org/jon/lv/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Package org.jon.lv.controller.HomeController 8 | * @Description: HomeController 9 | * @Copyright: Copyright (c) 2016 10 | * Author lv bin 11 | * @date 2017/6/29 11:00 12 | * version V1.0.0 13 | */ 14 | @RestController 15 | public class HomeController { 16 | 17 | @RequestMapping("/index") 18 | public Object index() { 19 | return "index"; 20 | } 21 | 22 | @RequestMapping("/home") 23 | public Object home() { 24 | return "home"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /eureka-consumer/src/main/java/org/jon/lv/EurekaConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | @EnableDiscoveryClient 11 | @SpringBootApplication 12 | public class EurekaConsumerApplication { 13 | @Bean 14 | public RestTemplate restTemplate() { 15 | return new RestTemplate(); 16 | } 17 | public static void main(String[] args) { 18 | SpringApplication.run(EurekaConsumerApplication.class, args); 19 | } 20 | } -------------------------------------------------------------------------------- /eureka-consumer-feign/src/main/java/org/jon/lv/service/DemoService.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.service; 2 | 3 | import org.jon.lv.service.hystrix.DemoServiceHystrix; 4 | import org.springframework.cloud.netflix.feign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | /** 10 | * @Package org.jon.lv.service.DemoService 11 | * @Description: DemoService 12 | * @Copyright: Copyright (c) 2016 13 | * Author lv bin 14 | * @date 2017/6/28 10:57 15 | * version V1.0.0 16 | */ 17 | @FeignClient(value = "eureka-client", fallback = DemoServiceHystrix.class) 18 | public interface DemoService { 19 | @GetMapping(value= "/demo") 20 | String demo(); 21 | } 22 | -------------------------------------------------------------------------------- /config-eureka-server/src/main/java/org/jon/lv/ConfigEurekaServerApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | 8 | /** 9 | * @Package org.jon.lv.ConfigEurekaServerApplication 10 | * @Copyright: Copyright (c) 2016 11 | * Author lv bin 12 | * @date 2017/7/4 13:35 13 | * version V1.0.0 14 | */ 15 | @SpringBootApplication 16 | @EnableConfigServer 17 | @EnableEurekaClient 18 | public class ConfigEurekaServerApplication { 19 | public static void main(String[] args) { 20 | SpringApplication.run(ConfigEurekaServerApplication.class, args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /config-server-eureka-bus/src/main/java/org/jon/lv/ConfigEurekaServerBusApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 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.cloud.config.server.EnableConfigServer; 7 | 8 | /** 9 | * @Package org.jon.lv.ConfigEurekaServerApplication 10 | * @Copyright: Copyright (c) 2016 11 | * Author lv bin 12 | * @date 2017/7/4 13:35 13 | * version V1.0.0 14 | */ 15 | @SpringBootApplication 16 | @EnableConfigServer 17 | @EnableDiscoveryClient 18 | public class ConfigEurekaServerBusApplication { 19 | public static void main(String[] args) { 20 | SpringApplication.run(ConfigEurekaServerBusApplication.class, args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /config-client-eureka-bus/src/main/java/org/jon/lv/web/DemoController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.web; 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.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Package org.jon.lv.web.DemoController 10 | * @Copyright: Copyright (c) 2016 11 | * Author lv bin 12 | * @date 2017/7/13 17:52 13 | * version V1.0.0 14 | */ 15 | @RestController 16 | @RefreshScope // 使用该注解的类,会在接到SpringCloud配置中心配置刷新的时候,自动将新的配置更新到该类对应的字段中。 17 | public class DemoController { 18 | 19 | @Value("${jon}") 20 | String jon = "default"; 21 | 22 | @RequestMapping(value = "/jon") 23 | public String jon(){ 24 | return jon; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /eureka-consumer-feign/src/main/java/org/jon/lv/controller/ConsumerController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.controller; 2 | 3 | import org.jon.lv.service.DemoService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @Package org.jon.lv.controller.DemoController 11 | * @Description: DemoController 12 | * @Copyright: Copyright (c) 2016 13 | * Author lv bin 14 | * @date 2017/6/27 15:42 15 | * version V1.0.0 16 | */ 17 | @RestController 18 | public class ConsumerController { 19 | 20 | @Autowired 21 | DemoService demoService; 22 | 23 | @GetMapping("/feign") 24 | public String feign(@RequestParam String name) { 25 | return name + "-----" + demoService.demo(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /config-client-eureka-bus/src/main/java/org/jon/lv/ConfigEurekaClientBusApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | /** 10 | * @Package org.jon.lv.ConfigClientApplication 11 | * @Description: ConfigClientApplication 12 | * @Copyright: Copyright (c) 2016 13 | * Author lv bin 14 | * @date 2017/7/3 13:35 15 | * version V1.0.0 16 | */ 17 | 18 | @SpringBootApplication 19 | @EnableDiscoveryClient 20 | public class ConfigEurekaClientBusApplication { 21 | 22 | public static void main(String[] args) { 23 | SpringApplication.run(ConfigEurekaClientBusApplication.class, args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /consul-client/src/main/java/org/jon/lv/controller/DemoController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.client.discovery.DiscoveryClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * @Package org.jon.lv.controller.DemoController 10 | * @Description: DemoController 11 | * @Copyright: Copyright (c) 2016 12 | * Author lv bin 13 | * @date 2017/6/27 15:42 14 | * version V1.0.0 15 | */ 16 | @RestController 17 | public class DemoController { 18 | 19 | @Autowired 20 | DiscoveryClient discoveryClient; 21 | 22 | @GetMapping("/demo") 23 | public String demo() { 24 | String services = "Services: " + discoveryClient.getServices(); 25 | System.out.println(services); 26 | return services; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon-hystrix/src/main/java/org/jon/lv/controller/ConsumerController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.controller; 2 | 3 | import org.jon.lv.service.DemoService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | /** 11 | * @Package org.jon.lv.controller.DemoController 12 | * @Description: DemoController 13 | * @Copyright: Copyright (c) 2016 14 | * Author lv bin 15 | * @date 2017/6/27 15:42 16 | * version V1.0.0 17 | */ 18 | @RestController 19 | public class ConsumerController { 20 | 21 | @Autowired 22 | DemoService demoService; 23 | 24 | @GetMapping("/ribbon") 25 | public String ribbon(@RequestParam String name) { 26 | return demoService.ribbon(name); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon-hystrix/src/main/java/org/jon/lv/service/DemoService.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.service; 2 | 3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | /** 9 | * @Package org.jon.lv.service.DemoService 10 | * @Description: DemoService 11 | * @Copyright: Copyright (c) 2016 12 | * Author lv bin 13 | * @date 2017/6/28 13:58 14 | * version V1.0.0 15 | */ 16 | @Service 17 | public class DemoService { 18 | 19 | @Autowired 20 | RestTemplate restTemplate; 21 | 22 | @HystrixCommand(fallbackMethod = "ribbonError") 23 | public String ribbon(String name) { 24 | return name + "----" +restTemplate.getForObject("http://eureka-client/demo", String.class); 25 | } 26 | 27 | public String ribbonError(String name) { 28 | return "hi,"+name+",sorry, net error!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon/src/main/java/org/jon/lv/controller/ConsumerController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.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.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | /** 11 | * @Package org.jon.lv.controller.DemoController 12 | * @Description: DemoController 13 | * @Copyright: Copyright (c) 2016 14 | * Author lv bin 15 | * @date 2017/6/27 15:42 16 | * version V1.0.0 17 | */ 18 | @RestController 19 | public class ConsumerController { 20 | 21 | @Autowired 22 | RestTemplate restTemplate; 23 | 24 | @GetMapping("/ribbon") 25 | public String ribbon() { 26 | return restTemplate.getForObject("http://eureka-client/demo", String.class); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /config-client/src/main/java/org/jon/lv/ConfigClientApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @Package org.jon.lv.ConfigClientApplication 11 | * @Description: ConfigClientApplication 12 | * @Copyright: Copyright (c) 2016 13 | * Author lv bin 14 | * @date 2017/7/3 13:35 15 | * version V1.0.0 16 | */ 17 | 18 | @RestController 19 | @SpringBootApplication 20 | public class ConfigClientApplication { 21 | 22 | @Value("${jon}") 23 | String jon; 24 | 25 | @RequestMapping(value = "/jon") 26 | public String jon(){ 27 | return jon; 28 | } 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(ConfigClientApplication.class, args); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon/src/main/java/org/jon/lv/EurekaConsumerRibbonApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | @EnableDiscoveryClient 12 | @SpringBootApplication 13 | public class EurekaConsumerRibbonApplication { 14 | @Bean 15 | @LoadBalanced 16 | public RestTemplate restTemplate() { 17 | 18 | /** 19 | * Spring Cloud Ribbon的时候,不论是与Eureka还是Consul结合, 20 | * 都会在引入Spring Cloud Eureka或Spring Cloud Consul依赖的时候通过自动化配置来加载上述所说的配置内容, 21 | * 所以我们可以快速在Spring Cloud中实现服务间调用的负载均衡。 22 | */ 23 | 24 | return new RestTemplate(); 25 | } 26 | public static void main(String[] args) { 27 | 28 | SpringApplication.run(EurekaConsumerRibbonApplication.class, args); 29 | } 30 | } -------------------------------------------------------------------------------- /eureka-client/src/main/java/org/jon/lv/controller/DemoController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.client.discovery.DiscoveryClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.Mapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @Package org.jon.lv.controller.DemoController 12 | * @Description: DemoController 13 | * @Copyright: Copyright (c) 2016 14 | * Author lv bin 15 | * @date 2017/6/27 15:42 16 | * version V1.0.0 17 | */ 18 | @RestController 19 | public class DemoController { 20 | 21 | @Autowired 22 | DiscoveryClient discoveryClient; 23 | 24 | @GetMapping("/demo") 25 | public String demo() { 26 | String services = "Services: " + discoveryClient.getServices(); 27 | System.out.println(services); 28 | return services; 29 | } 30 | 31 | @GetMapping("/name") 32 | public String name(@RequestParam String name) { 33 | return "-----------------:" + name; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon-hystrix/src/main/java/org/jon/lv/EurekaConsumerRibbonHystrixApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.web.client.RestTemplate; 11 | 12 | @EnableDiscoveryClient 13 | @SpringBootApplication 14 | @EnableHystrix 15 | public class EurekaConsumerRibbonHystrixApplication { 16 | @Bean 17 | @LoadBalanced 18 | public RestTemplate restTemplate() { 19 | 20 | /** 21 | * Spring Cloud Ribbon的时候,不论是与Eureka还是Consul结合, 22 | * 都会在引入Spring Cloud Eureka或Spring Cloud Consul依赖的时候通过自动化配置来加载上述所说的配置内容, 23 | * 所以我们可以快速在Spring Cloud中实现服务间调用的负载均衡。 24 | */ 25 | 26 | return new RestTemplate(); 27 | } 28 | public static void main(String[] args) { 29 | 30 | SpringApplication.run(EurekaConsumerRibbonHystrixApplication.class, args); 31 | } 32 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.jon.lv 6 | springcloudexample 7 | 1.0-SNAPSHOT 8 | 9 | eureka-server 10 | eureka-client 11 | consul-client 12 | eureka-consumer 13 | eureka-consumer-ribbon 14 | eureka-consumer-feign 15 | eureka-consumer-ribbon-hystrix 16 | eureka-zuul 17 | config-server 18 | config-client 19 | config-eureka-server 20 | config-eureka-client 21 | config-server-eureka-bus 22 | config-client-eureka-bus 23 | 24 | pom 25 | 26 | springcloudexample 27 | http://maven.apache.org 28 | 29 | 30 | UTF-8 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /config-eureka-client/src/main/java/org/jon/lv/ConfigEurekaClientApplication.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.context.config.annotation.RefreshScope; 7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * @Package org.jon.lv.ConfigClientApplication 13 | * @Description: ConfigClientApplication 14 | * @Copyright: Copyright (c) 2016 15 | * Author lv bin 16 | * @date 2017/7/3 13:35 17 | * version V1.0.0 18 | */ 19 | 20 | @SpringBootApplication 21 | @EnableEurekaClient 22 | @RestController 23 | @RefreshScope // 使用该注解的类,会在接到SpringCloud配置中心配置刷新的时候,自动将新的配置更新到该类对应的字段中。 24 | public class ConfigEurekaClientApplication { 25 | 26 | @Value("${jon}") 27 | String jon; 28 | 29 | @RequestMapping(value = "/jon") 30 | public String jon(){ 31 | return jon; 32 | } 33 | 34 | public static void main(String[] args) { 35 | SpringApplication.run(ConfigEurekaClientApplication.class, args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /eureka-consumer/src/main/java/org/jon/lv/controller/ConsumerController.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.client.ServiceInstance; 5 | import org.springframework.cloud.client.discovery.DiscoveryClient; 6 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 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 | /** 12 | * @Package org.jon.lv.controller.DemoController 13 | * @Description: DemoController 14 | * @Copyright: Copyright (c) 2016 15 | * Author lv bin 16 | * @date 2017/6/27 15:42 17 | * version V1.0.0 18 | */ 19 | @RestController 20 | public class ConsumerController { 21 | 22 | @Autowired 23 | LoadBalancerClient loadBalancerClient; //LoadBalancerClient接口的命名中,我们就知道这是一个负载均衡客户端的抽象定义 24 | @Autowired 25 | RestTemplate restTemplate; 26 | 27 | @GetMapping("/consumer") 28 | public String consumer() { 29 | 30 | /** 31 | * consumer接口的实现中,先通过loadBalancerClient的choose函数来负载均衡的选出一个eureka-client的服务实例, 32 | * 这个服务实例的基本信息存储在ServiceInstance中,然后通过这些对象中的信息拼接出访问/dc接口的详细地址, 33 | * 最后再利用RestTemplate对象实现对服务提供者接口的调用。 34 | * 35 | * eureka-server、eureka-client、eureka-consumer都启动 36 | * 访问http://localhost:2101/consumer ,来跟踪观察eureka-consumer服务是如何消费eureka-client服务的/dc接口的 37 | */ 38 | 39 | ServiceInstance serviceInstance = loadBalancerClient.choose("eureka-client"); 40 | String url = "http://" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + "/demo"; 41 | 42 | System.out.println("******************************" + url); 43 | 44 | return restTemplate.getForObject(url, String.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /config-server/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.2.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | config-server 13 | jar 14 | 15 | config-server 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 1.7 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-config-server 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR6 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /eureka-zuul/src/main/java/org/jon/lv/filter/DemoFilter.java: -------------------------------------------------------------------------------- 1 | package org.jon.lv.filter; 2 | 3 | import com.netflix.zuul.ZuulFilter; 4 | import com.netflix.zuul.context.RequestContext; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | /** 10 | * @Package org.jon.lv.filter.DemoFilter 11 | * @Copyright: Copyright (c) 2016 12 | * Author lv bin 13 | * @date 2017/6/29 13:28 14 | * version V1.0.0 15 | */ 16 | @Component 17 | public class DemoFilter extends ZuulFilter { 18 | 19 | @Override 20 | public String filterType() { 21 | 22 | /** 23 | * filterType:返回一个字符串代表过滤器的类型,在zuul中定义了四种不同生命周期的过滤器类型,具体如下: 24 | * pre:路由之前 25 | * routing:路由之时 26 | * post: 路由之后 27 | * error:发送错误调用 28 | * filterOrder:过滤的顺序 29 | * shouldFilter:这里可以写逻辑判断,是否要过滤,本文true,永远过滤。 30 | * run:过滤器的具体逻辑。可用很复杂,包括查sql,nosql去判断该请求到底有没有权限访问。 31 | */ 32 | 33 | return "pre"; 34 | } 35 | 36 | @Override 37 | public int filterOrder() { 38 | return 0; 39 | } 40 | 41 | @Override 42 | public boolean shouldFilter() { 43 | return true; 44 | } 45 | 46 | @Override 47 | public Object run() { 48 | RequestContext ctx = RequestContext.getCurrentContext(); 49 | HttpServletRequest request = ctx.getRequest(); 50 | System.out.println(String.format("%s >>> %s", request.getMethod(), request.getRequestURL().toString())); 51 | 52 | Object accessToken = request.getParameter("token"); 53 | 54 | if(accessToken == null) { 55 | ctx.setSendZuulResponse(false); 56 | ctx.setResponseStatusCode(401); 57 | try { 58 | ctx.getResponse().getWriter().write("token is empty"); 59 | }catch (Exception e){} 60 | 61 | return null; 62 | } 63 | 64 | System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ok"); 65 | 66 | return null; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /config-eureka-server/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.2.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | config-eureka-server 13 | jar 14 | 15 | config-eureka-server 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 1.7 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-config-server 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-test 32 | test 33 | 34 | 35 | 36 | org.springframework.cloud 37 | spring-cloud-starter-eureka 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-dependencies 46 | Camden.SR6 47 | pom 48 | import 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /config-client/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.2.RELEASE 8 | 9 | 10 | 4.0.0 11 | 12 | org.jon.lv 13 | config-client 14 | jar 15 | 16 | config-client 17 | http://maven.apache.org 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-starter-config 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.cloud 47 | spring-cloud-dependencies 48 | Camden.SR6 49 | pom 50 | import 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /eureka-client/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 10 | 4.0.0 11 | 12 | org.jon.lv 13 | eureka-client 14 | jar 15 | 16 | eureka-client 17 | http://maven.apache.org 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-eureka 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-dependencies 40 | Dalston.SR1 41 | pom 42 | import 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-surefire-plugin 53 | 2.4 54 | 55 | true 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /consul-client/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | consul-client 13 | jar 14 | 15 | consul-client 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-consul-discovery 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-dependencies 39 | Dalston.SR1 40 | pom 41 | import 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-surefire-plugin 52 | 2.4 53 | 54 | true 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-maven-plugin 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /eureka-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | eureka-consumer 13 | jar 14 | 15 | eureka-consumer 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-eureka 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-actuator 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.cloud 43 | spring-cloud-dependencies 44 | Dalston.SR1 45 | pom 46 | import 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-surefire-plugin 57 | 2.4 58 | 59 | true 60 | 61 | 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-maven-plugin 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /eureka-server/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 10 | 4.0.0 11 | 12 | org.jon.lv 13 | eureka-server 14 | jar 15 | 16 | eureka-server 17 | http://maven.apache.org 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-eureka-server 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-dependencies 46 | Dalston.SR1 47 | pom 48 | import 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-surefire-plugin 59 | 2.4 60 | 61 | true 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /config-server-eureka-bus/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | config-server-eureka-bus 13 | jar 14 | 15 | config-server-eureka-bus 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-config-server 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | test 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-eureka 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-starter-bus-kafka 42 | 43 | 44 | 45 | org.springframework.cloud 46 | spring-cloud-config-monitor 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.cloud 54 | spring-cloud-dependencies 55 | Brixton.SR5 56 | pom 57 | import 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /eureka-consumer-feign/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | eureka-consumer-feign 13 | jar 14 | 15 | eureka-consumer-feign 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-feign 26 | 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-eureka 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-actuator 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-dependencies 49 | Dalston.SR1 50 | pom 51 | import 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.apache.maven.plugins 61 | maven-surefire-plugin 62 | 2.4 63 | 64 | true 65 | 66 | 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-maven-plugin 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | eureka-consumer-ribbon 13 | jar 14 | 15 | eureka-consumer-ribbon 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-ribbon 26 | 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-eureka 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-actuator 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-dependencies 49 | Dalston.SR1 50 | pom 51 | import 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.apache.maven.plugins 61 | maven-surefire-plugin 62 | 2.4 63 | 64 | true 65 | 66 | 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-maven-plugin 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /eureka-zuul/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | eureka-zuul 13 | jar 14 | 15 | eureka-consumer-zuul 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-eureka 26 | 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-zuul 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-dependencies 50 | Dalston.SR1 51 | pom 52 | import 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.apache.maven.plugins 62 | maven-surefire-plugin 63 | 2.4 64 | 65 | true 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /config-eureka-client/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.2.RELEASE 8 | 9 | 10 | 4.0.0 11 | 12 | org.jon.lv 13 | config-eureka-client 14 | jar 15 | 16 | config-eureka-client 17 | http://maven.apache.org 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-config 29 | 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-eureka 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | true 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.cloud 59 | spring-cloud-dependencies 60 | Camden.SR6 61 | pom 62 | import 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon-hystrix/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | eureka-consumer-ribbon-hystrix 13 | jar 14 | 15 | eureka-consumer-ribbon-hystrix 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-hystrix 26 | 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-ribbon 31 | 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-eureka 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-actuator 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-dependencies 54 | Dalston.SR1 55 | pom 56 | import 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.apache.maven.plugins 66 | maven-surefire-plugin 67 | 2.4 68 | 69 | true 70 | 71 | 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-maven-plugin 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /config-client-eureka-bus/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | org.springframework.boot 5 | spring-boot-starter-parent 6 | 1.5.3.RELEASE 7 | 8 | 9 | 4.0.0 10 | 11 | org.jon.lv 12 | config-client-eureka-bus 13 | jar 14 | 15 | config-client-eureka-bus 16 | http://maven.apache.org 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-config 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-actuator 31 | true 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | org.springframework.cloud 47 | spring-cloud-starter-eureka 48 | 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-starter-bus-kafka 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-config-monitor 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.cloud 65 | spring-cloud-dependencies 66 | Brixton.SR5 67 | pom 68 | import 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.springframework.boot 78 | spring-boot-maven-plugin 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # springcloudexample 2 | **QQ交流群:374044564**
3 | **添加QQ群获取springboot、springcloud、dubbo等视频教程及资料**
4 | spring cloud 学习例子
5 | 在微服务架构中,需要几个关键的组件,服务注册与发现、服务消费、负载均衡、断路器、智能路由、配置管理等,
6 | 由这几个组件可以组建一个简单的微服务架构。
7 | 8 | 9 | 10 | ## 服务发现(Eureka、consul)
11 | + eureka-server(服务注册中心) http://localhost:1001/
12 | + eureka-client(服务提供方)http://localhost:2001/demo
13 | + eureka-consumer(服务消费者-手动负载均衡)http://localhost:2101/consumer
14 | + eureka-consumer-ribbon(服务消费者-自动负载均衡)http://localhost:2102/ribbon
15 | + Eureka简介:http://www.cnblogs.com/wangdaijun/p/6851027.html
16 | + Eureka简介:http://www.roncoo.com/article/detail/128041
17 | + **Note:先启动注册中心然后启动服务提供者**
18 | 19 | ### consul-client(consul服务提供方) 20 | + Spring Cloud Consul项目是针对Consul的服务治理实现
21 | + Consul特性:服务发现,健康检查,Key/Value存储,多数据中心
22 | + 由于Consul自身提供了服务端,所以我们不需要像之前实现Eureka的时候创建服务注册中心,
23 | + 直接通过下载consul的服务端程序就可以使用:
24 | + consul怎么在windows下安装:http://blog.csdn.net/forezp/article/details/70188595
25 | + consul下载地址:https://www.consul.io/downloads.html
26 | + windows pc 环境变量设置 在path下加上:E:\programfiles\consul; cmd启动运行 consul agent -dev
27 | + consul默认地址:http://localhost:8500
28 | + 访问demo:http://localhost:3001/demo
29 | + 服务发现系统consul介绍:http://www.tuicool.com/articles/j2YVB3
30 | 31 | ## 声明式REST客户端-Feign的使用
32 | + Feign是一种声明式、模板化的HTTP客户端。
33 | + 在Spring Cloud中使用Feign, 我们可以做到使用HTTP请求远程服务时能与调用本地方法一样的编码体验,开发者完全感知不到这是远程方法,更感知不到这是个HTTP请求。
34 | + eureka-consumer-feign(服务消费者-feign): http://localhost:2103/feign?name=jon
35 | + **feign是自带断路器的**,此版本hystrix是关闭的 ,如果使用feign想用断路器的话,可以在配置文件中开启它,配置如下:feign.hystrix.enabled=true
36 | 37 | ## 断路器(Hystrix)
38 | + eureka-consumer-ribbon-hystrix(服务消费者-断路器)
39 | + http://localhost:2104/ribbon?name=jon
40 | 41 | ## 智能路由(zuul)
42 | + Zuul的主要功能是路由和过滤器。 43 | + 路由功能是微服务的一部分,比如/api/user映射到user服务,/api/shop映射到shop服务。zuul实现了负载均衡。 44 | + 依次启动顺序 eureka-server、eureka-client、eureka-consumer、eureka-consumer-feign、eureka-zuul工程 45 | 依次访问下面的路径查看测试效果。 46 | + http://localhost:3101/baidu 47 | + http://localhost:3101/index 48 | + http://localhost:3101/api-a/consumer 49 | + http://localhost:3101/api-b/feign?name=jon 50 | 51 | ### 智能路由(zuul)- 过滤器ZuulFilter 52 | + 过滤器类型返回一个字符串代表过滤器的类型,在zuul中定义了四种不同生命周期的过滤器类型,具体如下:filterType如下: 53 | 1. pre:路由之前 54 | 2. routing:路由之时 55 | 3. post: 路由之后 56 | 4. error:发送错误调用 57 | 5. filterOrder:过滤的顺序 58 | 6. shouldFilter:这里可以写逻辑判断,是否要过滤,本文true,永远过滤。 59 | 7. run:过滤器的具体逻辑。可用很复杂,包括查sql,nosql去判断该请求到底有没有权限访问。 60 | + 参考代码 DemoFilter 61 | + 修改请求地址 62 | 1. http://localhost:3101/baidu?token=org.lv.jon.token 63 | 2. http://localhost:3101/index?token=org.lv.jon.token 64 | 3. http://localhost:3101/api-a/consumer?token=org.lv.jon.token 65 | 4. http://localhost:3101/api-b/feign?name=jon&token=org.lv.jon.token 66 | 67 | ## 分布式配置中心(Spring Cloud Config) 68 | 在分布式系统中,spring cloud config 提供一个服务端和客户端去提供可扩展的配置服务。 69 | 我们可用用配置服务中心区集中的管理所有的服务的各种环境配置文件。配置服务中心采用Git的方式存储配置文件, 70 | 因此我们很容易部署修改,有助于对环境配置进行版本管理。 71 | ### config-server 72 | 高可用配置中心 config-eureka-server 使用eureka做为配置服务注册中心,需要启动eureka-server配合使用。 73 | #### 访问配置信息的URL与配置文件的映射关系如下: 74 | * /{application}/{profile}[/{label}] 75 | * /{application}-{profile}.yml 76 | * /{label}/{application}-{profile}.yml 77 | * /{application}-{profile}.properties 78 | * /{label}/{application}-{profile}.properties 79 | application:表示应用名称,在client中通过spring.config.name配置,profile:表示获取指定环境下配置,例如开发环境、测试环境、生产环境 默认值default,实际开发中可以是 dev、test、demo、production等 80 | label: git标签,默认值master 81 | * http://localhost:8888/config-client/dev 82 | ### config-client 83 | **config-client 配置文件必须要使用bootstrap.properties**
84 | 高可用配置中心客户端 config-eureka-client 使用eureka做为配置服务注册中心,需要启动eureka-server,config-eureka-server配合使用。 85 | http://localhost:8001/jon 86 | * 启动config-server 然后启动config-server 访问http://localhost:8800/jon 87 | ### 动态更新配置参数 88 | 1. 在客户端启动类添加注解 @RefreshScope 使用该注解的类,会在接到SpringCloud配置中心配置刷新的时候,自动将新的配置更新到该类对应的字段中。 89 | 2. 在客户端pom增加spring-boot-starter-actuator包,spring-boot-starter-actuator是一套监控的功能,可以监控程序在运行时状态,其中就包括/refresh的功能。 90 | 3. springboot 1.5.X 以上默认开通了安全认证,所以需要在配置文件application.properties中关闭安全认证:management.security.enabled=false 91 | 4. 以post请求的方式来访问http://localhost:8001/refresh 就会更新修改后的配置文件。 92 | 5. 查看更新后的参数 http://localhost:8001/jon 93 | 94 | ## 消息总线(Spring Cloud Bus) 95 | SpringCloudConfig分服务端和客户端,服务端负责将git(svn)中存储的配置文件发布成REST接口,客户端可以从服务端REST接口获取配置。 96 | 但客户端并不能主动感知到配置的变化,从而主动去获取新的配置,这需要每个客户端通过POST方法触发各自的/refresh。 97 | 若所有触发操作均需要我们手工去维护系统中的应用位置的话,这随着系统的不断扩张,会变的越来越难以维护, 98 | 而消息代理中间件是解决该问题最为合适的方案。消息代理中间件可以将消息路由到一个或多个目的地。 99 | 利用这个功能,我们就能完美的解决该问题。 100 | 注意kafka版本与springcloud版本兼容问题本工程spring-cloud-dependencies版本修改为Brixton.SR5 101 | #### kafka方式实现消息总线 需配合eureka注册中心使用 eureka-server 102 | 1. 服务端config-server-eureka-bus 103 | application.properties配置 104 | #kafka配置 105 | spring.cloud.stream.kafka.binder.zk-nodes=192.168.88.177:2181 106 | spring.cloud.stream.kafka.binder.brokers=192.168.88.177:9092 107 | pom.xml配置 108 | 109 | org.springframework.cloud 110 | spring-cloud-starter-bus-kafka 111 | 112 | 2. 客服端config-client-eureka-bus 113 | bootstrap.properties配置 114 | #kafka配置 115 | spring.cloud.stream.kafka.binder.zk-nodes=192.168.88.177:2181 116 | spring.cloud.stream.kafka.binder.brokers=192.168.88.177:9092 117 | #开启消息跟踪 118 | spring.cloud.bus.trace.enabled=true 119 | 3. Spring Cloud Bus做配置更新步骤如下图: 120 | * 提交代码触发post请求给bus/refresh 121 | * server端接收到请求并发送给Spring Cloud Bus 122 | * Spring Cloud bus接到消息并通知给其它客户端 123 | * 其它客户端接收到通知,请求Server端获取最新配置 124 | * 全部客户端均获取到最新的配置 125 | 126 | 127 | 128 | #### 局部刷新配置 129 | 某些场景下(例如灰度发布),我们可能只想刷新部分微服务的配置,此时可通过/bus/refresh端点的destination参数来定位要刷新的应用程序。 130 | 例如:/bus/refresh?destination=customers:8000,这样消息总线上的微服务实例就会根据destination参数的值来判断是否需要要刷新。 131 | 其中,customers:8000指的是各个微服务的ApplicationContext ID。 132 | destination参数也可以用来定位特定的微服务。例如:/bus/refresh?destination=customers:**,这样就可以触发customers微服务所有实例的配置刷新。 133 | #### 跟踪总线事件 134 | 一些场景下,我们可能希望知道Spring Cloud Bus事件传播的细节。此时,我们可以跟踪总线事件(RemoteApplicationEvent的子类都是总线事件)。 135 | 跟踪总线事件非常简单,只需设置spring.cloud.bus.trace.enabled=true,这样在/bus/refresh端点被请求后,访问/trace端点就可获得类。 136 | #### /bus/refresh BUG 137 | 对客户端执行/bus/refresh之后,挂到总线的上的客户端都会从Eureka注册中心撤销登记; 138 | 如果对server端执行/bus/refresh,server端也会从Eureka注册中心撤销登记。 139 | Spring Cloud的Dalston.SR1版本,解决这个bug. 140 | 141 | ## 服务链路追踪(Spring Cloud Sleuth) 142 | 143 | ## 高可用的服务注册中心 144 | 145 | ## 断路器监控(Hystrix Dashboard) 146 | 147 | ## 断路器聚合监控(Hystrix Turbine) 148 | 149 | -------------------------------------------------------------------------------- /eureka-zuul/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /config-client/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /config-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /consul-client/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /eureka-client/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /eureka-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /eureka-consumer/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /config-eureka-client/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /config-eureka-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /eureka-consumer-feign/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /eureka-consumer-ribbon/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /config-client-eureka-bus/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /config-server-eureka-bus/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | SpringBootDemo 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n 31 | 32 | 33 | 34 | 35 | 36 | 37 | ${LOG_PATH}/${APP_DIR}/log_error.log 38 | 39 | 40 | 42 | ${LOG_PATH}/${APP_DIR}/error/log-error-%d{yyyy-MM-dd}.%i.log 43 | 45 | 46 | 2MB 47 | 48 | 49 | 50 | true 51 | 52 | 53 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 54 | utf-8 55 | 56 | 57 | 58 | error 59 | ACCEPT 60 | DENY 61 | 62 | 63 | 64 | 65 | 66 | 67 | ${LOG_PATH}/${APP_DIR}/log_warn.log 68 | 69 | 70 | 72 | ${LOG_PATH}/${APP_DIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 73 | 75 | 76 | 2MB 77 | 78 | 79 | 80 | true 81 | 82 | 83 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 84 | utf-8 85 | 86 | 87 | 88 | warn 89 | ACCEPT 90 | DENY 91 | 92 | 93 | 94 | 95 | 96 | 97 | ${LOG_PATH}/${APP_DIR}/log_info.log 98 | 99 | 100 | 102 | ${LOG_PATH}/${APP_DIR}/info/log-info-%d{yyyy-MM-dd}.%i.log 103 | 105 | 106 | 2MB 107 | 108 | 109 | 110 | true 111 | 112 | 113 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 114 | utf-8 115 | 116 | 117 | 118 | info 119 | ACCEPT 120 | DENY 121 | 122 | 123 | 124 | 125 | 126 | 127 | ${LOG_PATH}/${APP_DIR}/log_debug.log 128 | 129 | 130 | 132 | ${LOG_PATH}/${APP_DIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log 133 | 135 | 136 | 2MB 137 | 138 | 139 | 140 | true 141 | 142 | 143 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n 144 | utf-8 145 | 146 | 147 | 148 | DEBUG 149 | ACCEPT 150 | DENY 151 | 152 | 153 | 154 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 206 | 207 | 212 | 213 | 214 | 226 | 227 | 228 | 229 | --------------------------------------------------------------------------------