├── .gitignore ├── README.md ├── alibaba-provider-payment9001 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── PaymentMain9001.java │ │ └── controller │ │ └── PaymentController.java │ └── resources │ └── application.yml ├── alibaba-provider-payment9002 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── PaymentMain9002.java │ │ └── controller │ │ └── PaymentController.java │ └── resources │ └── application.yml ├── cloud-api-commons ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── yyb │ └── springcloud │ └── entity │ ├── CommonResult.java │ └── Payment.java ├── cloud-config-center3344 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ └── ConfigCenterMain3344.java │ └── resources │ └── application.yml ├── cloud-config-client3355 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── ConfigClientMain3355.java │ │ └── controller │ │ └── ConfigClientController.java │ └── resources │ └── bootstrap.yml ├── cloud-config-client3366 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── ConfigClientMain3366.java │ │ └── controller │ │ └── ConfigClientController.java │ └── resources │ └── bootstrap.yml ├── cloud-consumer-feign-hystrix-order80 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── OrderFeignHystrixMain80.java │ │ ├── controller │ │ └── OrderController.java │ │ └── service │ │ └── OrderFeignService.java │ └── resources │ └── application.yml ├── cloud-consumer-feign-order80 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── OrderFeignMain80.java │ │ ├── controller │ │ └── OrderController.java │ │ └── service │ │ └── OrderFeignService.java │ └── resources │ └── application.yml ├── cloud-consumer-hystrix-dashborad-order9001 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ └── OrderHystrixDashboardMain9001.java │ └── resources │ └── application.yml ├── cloud-consumer-order80 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── OrderMain80.java │ │ ├── config │ │ └── ApplicationContextConfig.java │ │ └── controller │ │ └── OrderController.java │ └── resources │ └── application.yml ├── cloud-consumerZK-order80 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── OrderZkMain80.java │ │ ├── config │ │ └── ApplicationContextConfig.java │ │ └── controller │ │ └── OrderController.java │ └── resources │ └── application.yml ├── cloud-eureka-server7001 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ └── EurekaMain7001.java │ └── resources │ └── application.yml ├── cloud-eureka-server7002 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ └── EurekaMain7002.java │ └── resources │ └── application.yml ├── cloud-eureka-server7003 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ └── EurekaMain7003.java │ └── resources │ └── application.yml ├── cloud-gateway9527 ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yyb │ │ │ └── springcloud │ │ │ ├── GatewayMain9527.java │ │ │ └── config │ │ │ └── MyLogGatewayFilter.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── Test.java ├── cloud-provider-hystrix-payment8001 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── PaymentHystrixMain8001.java │ │ ├── controller │ │ └── PaymentController.java │ │ └── service │ │ ├── PaymentService.java │ │ └── impl │ │ └── PaymentServiceImpl.java │ └── resources │ └── application.yml ├── cloud-provider-payment8001 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── PaymentMain8001.java │ │ ├── controller │ │ ├── PaymentController.java │ │ └── TestController.java │ │ ├── dao │ │ └── PaymentDao.java │ │ └── service │ │ ├── PaymentService.java │ │ └── impl │ │ └── PaymentServiceImpl.java │ └── resources │ ├── application.yml │ └── mapper │ └── PaymentMapper.xml ├── cloud-provider-payment8002 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── PaymentMain8002.java │ │ ├── controller │ │ ├── PaymentController.java │ │ └── TestController.java │ │ ├── dao │ │ └── PaymentDao.java │ │ └── service │ │ ├── PaymentService.java │ │ └── impl │ │ └── PaymentServiceImpl.java │ └── resources │ ├── application.yml │ └── mapper │ └── PaymentMapper.xml ├── cloud-provider-payment8004 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yyb │ │ └── springcloud │ │ ├── PaymentZkMain8004.java │ │ ├── controller │ │ └── PaymentController.java │ │ ├── dao │ │ └── PaymentDao.java │ │ └── service │ │ ├── PaymentService.java │ │ └── impl │ │ └── PaymentServiceImpl.java │ └── resources │ └── application.yml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # 项目排除路径 2 | /alibaba-provider-payment9001/target/ 3 | /alibaba-provider-payment9002/target/ 4 | /cloud-api-commons/target/ 5 | /cloud-config-center3344/target/ 6 | /cloud-config-client3355/target/ 7 | /cloud-config-client3366/target/ 8 | /cloud-consumer-feign-hystrix-order80/target/ 9 | /cloud-consumer-feign-order80/target/ 10 | /cloud-consumer-hystrix-dashborad-order9001/target/ 11 | /cloud-consumer-order80/target/ 12 | /cloud-consumerZK-order80/target/ 13 | /cloud-eureka-server7001/target/ 14 | /cloud-eureka-server7002/target/ 15 | /cloud-eureka-server7003/target/ 16 | /cloud-gateway9527/target/ 17 | /cloud-provider-hystrix-payment8001/target/ 18 | /cloud-provider-payment8001/target/ 19 | /cloud-provider-payment8002/target/ 20 | /cloud-provider-payment8004/target/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # springcloud 2 | 学习SpringCloud微服务框架时编写的项目。基于Spring Cloud Hoxton及SpringBoot 2.2.2,包含eureka、feign、hystrix、gateway、zookeeper、nacos等微服务组件 3 | -------------------------------------------------------------------------------- /alibaba-provider-payment9001/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | alibaba-provider-payment9001 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | com.alibaba.cloud 22 | spring-cloud-starter-alibaba-nacos-discovery 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-actuator 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-devtools 35 | runtime 36 | true 37 | 38 | 39 | org.projectlombok 40 | lombok 41 | true 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | com.alibaba 50 | fastjson 51 | 1.2.62 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /alibaba-provider-payment9001/src/main/java/com/yyb/springcloud/PaymentMain9001.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @EnableDiscoveryClient 8 | @SpringBootApplication 9 | public class PaymentMain9001 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(PaymentMain9001.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /alibaba-provider-payment9001/src/main/java/com/yyb/springcloud/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class PaymentController { 10 | @Value("${server.port}") 11 | private String serverPort; 12 | 13 | @GetMapping(value = "/payment/nacos/{id}") 14 | public String getPayment(@PathVariable("id") Integer id) { 15 | return "nacos registry, serverPort: " + serverPort + "\t id" + id; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /alibaba-provider-payment9001/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9001 3 | 4 | spring: 5 | application: 6 | name: alibaba-payment-provider 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: localhost:8848 #配置Nacos地址 11 | 12 | management: 13 | endpoints: 14 | web: 15 | exposure: 16 | include: '*' 17 | -------------------------------------------------------------------------------- /alibaba-provider-payment9002/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | alibaba-provider-payment9002 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | com.alibaba.cloud 22 | spring-cloud-starter-alibaba-nacos-discovery 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-actuator 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-devtools 35 | runtime 36 | true 37 | 38 | 39 | org.projectlombok 40 | lombok 41 | true 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | com.alibaba 50 | fastjson 51 | 1.2.62 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /alibaba-provider-payment9002/src/main/java/com/yyb/springcloud/PaymentMain9002.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @EnableDiscoveryClient 8 | @SpringBootApplication 9 | public class PaymentMain9002 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(PaymentMain9002.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /alibaba-provider-payment9002/src/main/java/com/yyb/springcloud/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class PaymentController { 10 | @Value("${server.port}") 11 | private String serverPort; 12 | 13 | @GetMapping(value = "/payment/nacos/{id}") 14 | public String getPayment(@PathVariable("id") Integer id) { 15 | return "nacos registry, serverPort: " + serverPort + "\t id" + id; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /alibaba-provider-payment9002/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9002 3 | 4 | spring: 5 | application: 6 | name: alibaba-payment-provider 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: localhost:8848 #配置Nacos地址 11 | 12 | management: 13 | endpoints: 14 | web: 15 | exposure: 16 | include: '*' 17 | -------------------------------------------------------------------------------- /cloud-api-commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-api-commons 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-devtools 22 | runtime 23 | true 24 | 25 | 26 | org.projectlombok 27 | lombok 28 | true 29 | 30 | 31 | cn.hutool 32 | hutool-all 33 | 5.1.0 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /cloud-api-commons/src/main/java/com/yyb/springcloud/entity/CommonResult.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CommonResult { 11 | 12 | private Integer code; 13 | private String message; 14 | private T data; 15 | 16 | public CommonResult(Integer code, String message) { 17 | this(code, message, null); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cloud-api-commons/src/main/java/com/yyb/springcloud/entity/Payment.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class Payment { 11 | 12 | private Long id; 13 | private String serial; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cloud-config-center3344/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-config-center3344 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | com.yyb 30 | cloud-api-commons 31 | 1.0-SNAPSHOT 32 | compile 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-client 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-devtools 42 | runtime 43 | true 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | true 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-config-server 58 | 59 | 60 | org.springframework.cloud 61 | spring-cloud-starter-bus-amqp 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /cloud-config-center3344/src/main/java/com/yyb/springcloud/ConfigCenterMain3344.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigCenterMain3344 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ConfigCenterMain3344.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-config-center3344/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 3344 3 | spring: 4 | application: 5 | name: cloud-config-center 6 | cloud: 7 | config: 8 | server: 9 | git: 10 | # github上的仓库名称 11 | # uri: git@github.com:AidenYoung100/springcloud-config.git 12 | uri: https://github.com/AidenYoung100/springcloud-config.git 13 | username: yungyunbo@gmail.com 14 | password: yyb1415. 15 | # 搜索路径 16 | search-paths: 17 | - springcloud-config 18 | # 读取分支 19 | label: master 20 | rabbitmq: 21 | host: 192.168.1.154 22 | port: 5672 23 | username: guest 24 | password: guest 25 | eureka: 26 | client: 27 | service-url: 28 | defaultZone: http://localhost:7001/eureka 29 | 30 | management: 31 | endpoints: 32 | web: 33 | exposure: 34 | include: 'bus-refresh' 35 | -------------------------------------------------------------------------------- /cloud-config-client3355/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-config-client3355 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | com.yyb 30 | cloud-api-commons 31 | 1.0-SNAPSHOT 32 | compile 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-client 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-devtools 42 | runtime 43 | true 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | true 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-config 58 | 59 | 60 | org.springframework.cloud 61 | spring-cloud-starter-bus-amqp 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /cloud-config-client3355/src/main/java/com/yyb/springcloud/ConfigClientMain3355.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.context.config.annotation.RefreshScope; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | 8 | @SpringBootApplication 9 | @EnableEurekaClient 10 | @RefreshScope 11 | public class ConfigClientMain3355 { 12 | public static void main(String[] args) { 13 | SpringApplication.run(ConfigClientMain3355.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cloud-config-client3355/src/main/java/com/yyb/springcloud/controller/ConfigClientController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class ConfigClientController { 9 | 10 | @Value("${config.info}") 11 | private String configInfo; 12 | 13 | @GetMapping("/configInfo") 14 | public String getConfigInfo() { 15 | return configInfo; 16 | } 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /cloud-config-client3355/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 3355 3 | spring: 4 | application: 5 | name: cloud-config-client 6 | cloud: 7 | config: 8 | uri: http://localhost:3344 9 | label: master 10 | name: config 11 | profile: dev 12 | rabbitmq: 13 | host: 192.168.1.154 14 | port: 5672 15 | username: guest 16 | password: guest 17 | eureka: 18 | client: 19 | service-url: 20 | defaultZone: http://localhost:7001/eureka 21 | management: 22 | endpoints: 23 | web: 24 | exposure: 25 | include: '*' 26 | -------------------------------------------------------------------------------- /cloud-config-client3366/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-config-client3366 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | com.yyb 30 | cloud-api-commons 31 | 1.0-SNAPSHOT 32 | compile 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-client 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-devtools 42 | runtime 43 | true 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | true 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-config 58 | 59 | 60 | org.springframework.cloud 61 | spring-cloud-starter-bus-amqp 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /cloud-config-client3366/src/main/java/com/yyb/springcloud/ConfigClientMain3366.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.context.config.annotation.RefreshScope; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | 8 | @SpringBootApplication 9 | @EnableEurekaClient 10 | @RefreshScope 11 | public class ConfigClientMain3366 { 12 | public static void main(String[] args) { 13 | SpringApplication.run(ConfigClientMain3366.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cloud-config-client3366/src/main/java/com/yyb/springcloud/controller/ConfigClientController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class ConfigClientController { 9 | 10 | @Value("${config.info}") 11 | private String configInfo; 12 | 13 | @GetMapping("/configInfo") 14 | public String getConfigInfo() { 15 | return configInfo; 16 | } 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /cloud-config-client3366/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 3366 3 | spring: 4 | application: 5 | name: cloud-config-client 6 | cloud: 7 | config: 8 | uri: http://localhost:3344 9 | label: master 10 | name: config 11 | profile: dev 12 | rabbitmq: 13 | host: 192.168.1.154 14 | port: 5672 15 | username: guest 16 | password: guest 17 | eureka: 18 | client: 19 | service-url: 20 | defaultZone: http://localhost:7001/eureka 21 | 22 | management: 23 | endpoints: 24 | web: 25 | exposure: 26 | include: '*' 27 | -------------------------------------------------------------------------------- /cloud-consumer-feign-hystrix-order80/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-consumer-feign-hystrix-order80 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-devtools 32 | runtime 33 | true 34 | 35 | 36 | org.projectlombok 37 | lombok 38 | true 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | com.yyb 47 | cloud-api-commons 48 | 1.0-SNAPSHOT 49 | compile 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-starter-netflix-eureka-client 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-openfeign 58 | 59 | 60 | org.springframework.cloud 61 | spring-cloud-starter-netflix-hystrix 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /cloud-consumer-feign-hystrix-order80/src/main/java/com/yyb/springcloud/OrderFeignHystrixMain80.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | @SpringBootApplication 10 | @EnableEurekaClient 11 | @EnableFeignClients 12 | @EnableHystrix 13 | public class OrderFeignHystrixMain80 { 14 | public static void main(String[] args) { 15 | SpringApplication.run(OrderFeignHystrixMain80.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cloud-consumer-feign-hystrix-order80/src/main/java/com/yyb/springcloud/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties; 4 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 5 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; 6 | import com.yyb.springcloud.service.OrderFeignService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import javax.annotation.Resource; 15 | 16 | @RestController 17 | @RequestMapping("/consumer") 18 | @Slf4j 19 | @EnableEurekaClient 20 | @DefaultProperties(defaultFallback = "defaultHandle") 21 | public class OrderController { 22 | @Resource 23 | private OrderFeignService orderFeignService; 24 | 25 | @GetMapping("/paymentOk/{id}") 26 | public String paymentOk(@PathVariable("id") int id) { 27 | return orderFeignService.paymentOk(id); 28 | } 29 | 30 | @GetMapping("/paymentTimeout/{id}") 31 | // @HystrixCommand(fallbackMethod = "paymentTimeoutHandle", commandProperties = { 32 | // @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "2000") 33 | // }) 34 | @HystrixCommand 35 | public String paymentTimeout(@PathVariable("id") int id) { 36 | return orderFeignService.paymentTimeout(id); 37 | } 38 | 39 | public String paymentTimeoutHandle(@PathVariable("id") int id) { 40 | return "消费者80服务出错,请稍后再试"; 41 | } 42 | 43 | public String defaultHandle() { 44 | return "全局降级方法"; 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /cloud-consumer-feign-hystrix-order80/src/main/java/com/yyb/springcloud/service/OrderFeignService.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | @Component 9 | @FeignClient("cloud-payment-hystrix-service") 10 | public interface OrderFeignService { 11 | 12 | @GetMapping("/payment/paymentOk/{id}") 13 | String paymentOk(@PathVariable("id") int id); 14 | 15 | @GetMapping("/payment/paymentTimeout/{id}") 16 | String paymentTimeout(@PathVariable("id") int id); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cloud-consumer-feign-hystrix-order80/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 80 3 | spring: 4 | application: 5 | name: cloud-order-service 6 | eureka: 7 | client: 8 | register-with-eureka: true 9 | fetch-registry: true 10 | service-url: 11 | defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 12 | feign: 13 | hystrix: 14 | enabled: true 15 | -------------------------------------------------------------------------------- /cloud-consumer-feign-order80/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-consumer-feign-order80 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-devtools 32 | runtime 33 | true 34 | 35 | 36 | org.projectlombok 37 | lombok 38 | true 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | com.yyb 47 | cloud-api-commons 48 | 1.0-SNAPSHOT 49 | compile 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-starter-netflix-eureka-client 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-openfeign 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /cloud-consumer-feign-order80/src/main/java/com/yyb/springcloud/OrderFeignMain80.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableEurekaClient 10 | @EnableFeignClients 11 | public class OrderFeignMain80 { 12 | public static void main(String[] args) { 13 | SpringApplication.run(OrderFeignMain80.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cloud-consumer-feign-order80/src/main/java/com/yyb/springcloud/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.yyb.springcloud.entity.CommonResult; 4 | import com.yyb.springcloud.entity.Payment; 5 | import com.yyb.springcloud.service.OrderFeignService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import javax.annotation.Resource; 14 | 15 | @RestController 16 | @RequestMapping("/consumer") 17 | @Slf4j 18 | @EnableEurekaClient 19 | public class OrderController { 20 | @Resource 21 | private OrderFeignService orderFeignService; 22 | 23 | @GetMapping("/payment/getPaymentById/{id}") 24 | public CommonResult getPaymentById(@PathVariable("id") Long id) { 25 | return orderFeignService.getPaymentById(id); 26 | } 27 | 28 | @GetMapping("/payment/timeout") 29 | String timeout() { 30 | return orderFeignService.timeout(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cloud-consumer-feign-order80/src/main/java/com/yyb/springcloud/service/OrderFeignService.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service; 2 | 3 | import com.yyb.springcloud.entity.CommonResult; 4 | import com.yyb.springcloud.entity.Payment; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | 10 | @Component 11 | @FeignClient("cloud-payment-service") 12 | public interface OrderFeignService { 13 | 14 | @GetMapping("/payment/getPaymentById/{id}") 15 | CommonResult getPaymentById(@PathVariable("id") Long id); 16 | 17 | @GetMapping("/payment/timeout") 18 | String timeout(); 19 | } 20 | -------------------------------------------------------------------------------- /cloud-consumer-feign-order80/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 80 3 | spring: 4 | application: 5 | name: cloud-order-service 6 | eureka: 7 | client: 8 | register-with-eureka: true 9 | fetch-registry: true 10 | service-url: 11 | defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 12 | ribbon: 13 | ReadTimeout: 5000 14 | ConnectTimeout: 5000 15 | -------------------------------------------------------------------------------- /cloud-consumer-hystrix-dashborad-order9001/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-consumer-hystrix-dashborad-order9001 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-actuator 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-devtools 52 | runtime 53 | true 54 | 55 | 56 | org.projectlombok 57 | lombok 58 | true 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-starter-test 63 | test 64 | 65 | 66 | org.springframework.cloud 67 | spring-cloud-starter-netflix-hystrix-dashboard 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /cloud-consumer-hystrix-dashborad-order9001/src/main/java/com/yyb/springcloud/OrderHystrixDashboardMain9001.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 6 | 7 | @SpringBootApplication 8 | @EnableHystrixDashboard 9 | public class OrderHystrixDashboardMain9001 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(OrderHystrixDashboardMain9001.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-consumer-hystrix-dashborad-order9001/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9001 3 | -------------------------------------------------------------------------------- /cloud-consumer-order80/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-consumer-order80 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-devtools 32 | runtime 33 | true 34 | 35 | 36 | org.projectlombok 37 | lombok 38 | true 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | com.yyb 47 | cloud-api-commons 48 | 1.0-SNAPSHOT 49 | compile 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-starter-netflix-eureka-client 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /cloud-consumer-order80/src/main/java/com/yyb/springcloud/OrderMain80.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | public class OrderMain80 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(OrderMain80.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-consumer-order80/src/main/java/com/yyb/springcloud/config/ApplicationContextConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.config; 2 | 3 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @Configuration 9 | public class ApplicationContextConfig { 10 | @Bean 11 | @LoadBalanced 12 | /* 开启负载均衡,使得服务消费者采用负载均衡(轮询)的方式调用服务提供者的服务。 */ 13 | public RestTemplate getRestTemplate() { 14 | return new RestTemplate(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cloud-consumer-order80/src/main/java/com/yyb/springcloud/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.yyb.springcloud.entity.CommonResult; 4 | import com.yyb.springcloud.entity.Payment; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | import javax.annotation.Resource; 14 | 15 | @RestController 16 | @Slf4j 17 | @EnableEurekaClient 18 | public class OrderController { 19 | 20 | @Resource 21 | private RestTemplate restTemplate; 22 | 23 | // public static final String PAYMENT_URL = "http://localhost:8001"; 24 | public static final String PAYMENT_URL = "http://CLOUD-PAYMENT-SERVICE"; 25 | 26 | @GetMapping("/consumer/payment/createPayment") 27 | public CommonResult createPayment(Payment payment) { 28 | return restTemplate.postForObject(PAYMENT_URL + "/payment/addPayment", payment, CommonResult.class); 29 | } 30 | 31 | @GetMapping("/consumer/payment/getPaymentById/{id}") 32 | public CommonResult getPaymentById(@PathVariable("id") Long id) { 33 | return restTemplate.getForObject(PAYMENT_URL + "/payment/getPaymentById/" + id, CommonResult.class); 34 | } 35 | 36 | 37 | @GetMapping("/consumer/payment/createPayment2") 38 | public ResponseEntity createPayment2(Payment payment) { 39 | return restTemplate.postForEntity(PAYMENT_URL + "/payment/addPayment", payment, Payment.class); 40 | } 41 | 42 | @GetMapping("/consumer/payment/getPaymentById2/{id}") 43 | public CommonResult getPaymentById2(@PathVariable("id") Long id) { 44 | ResponseEntity entity = restTemplate.getForEntity(PAYMENT_URL + "/payment/getPaymentById/" + id, CommonResult.class); 45 | if (entity.getStatusCode().is2xxSuccessful()) { 46 | return entity.getBody(); 47 | } else { 48 | return new CommonResult(422, "获取失败"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /cloud-consumer-order80/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 80 3 | spring: 4 | application: 5 | name: cloud-order-service 6 | eureka: 7 | client: 8 | register-with-eureka: true #表示不向注册中心注册自己 9 | fetch-registry: true #表示自己就是注册中心,职责是维护服务实例,并不需要去检索服务 10 | service-url: 11 | defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 12 | -------------------------------------------------------------------------------- /cloud-consumerZK-order80/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-consumerZK-order80 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-devtools 32 | runtime 33 | true 34 | 35 | 36 | org.projectlombok 37 | lombok 38 | true 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | com.yyb 47 | cloud-api-commons 48 | 1.0-SNAPSHOT 49 | compile 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-starter-zookeeper-discovery 54 | 55 | 56 | 57 | org.apache.zookeeper 58 | zookeeper 59 | 60 | 61 | 62 | 63 | 64 | org.apache.zookeeper 65 | zookeeper 66 | 3.4.13 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /cloud-consumerZK-order80/src/main/java/com/yyb/springcloud/OrderZkMain80.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class OrderZkMain80 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(OrderZkMain80.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-consumerZK-order80/src/main/java/com/yyb/springcloud/config/ApplicationContextConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.config; 2 | 3 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @Configuration 9 | public class ApplicationContextConfig { 10 | @Bean 11 | @LoadBalanced 12 | /* 开启负载均衡,使得服务消费者采用负载均衡(轮询)的方式调用服务提供者的服务。 */ 13 | public RestTemplate getRestTemplate() { 14 | return new RestTemplate(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cloud-consumerZK-order80/src/main/java/com/yyb/springcloud/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.yyb.springcloud.entity.CommonResult; 4 | import com.yyb.springcloud.entity.Payment; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | import javax.annotation.Resource; 12 | 13 | @RestController 14 | @Slf4j 15 | public class OrderController { 16 | 17 | @Resource 18 | private RestTemplate restTemplate; 19 | 20 | // public static final String PAYMENT_URL = "http://localhost:8001"; 21 | // public static final String PAYMENT_URL = "http://CLOUD-PAYMENT-SERVICE"; 22 | public static final String PAYMENT_URL = "http://cloud-payment-service"; 23 | 24 | @GetMapping("/consumer/payment/createPayment") 25 | public CommonResult createPayment(Payment payment) { 26 | return restTemplate.postForObject(PAYMENT_URL + "/payment/addPayment", payment, CommonResult.class); 27 | } 28 | 29 | @GetMapping("/consumer/payment/getPaymentById/{id}") 30 | public CommonResult getPaymentById(@PathVariable("id") Long id) { 31 | return restTemplate.getForObject(PAYMENT_URL + "/payment/getPaymentById/" + id, CommonResult.class); 32 | } 33 | 34 | @GetMapping("/consumer/payment/getZk") 35 | public String getZkInfo() { 36 | return restTemplate.getForObject(PAYMENT_URL + "/payment/getZk", String.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /cloud-consumerZK-order80/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 80 3 | spring: 4 | application: 5 | name: cloud-order-service 6 | cloud: 7 | zookeeper: 8 | connect-string: localhost:2181 9 | -------------------------------------------------------------------------------- /cloud-eureka-server7001/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-eureka-server7001 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-netflix-eureka-server 23 | 24 | 25 | com.yyb 26 | cloud-api-commons 27 | ${project.version} 28 | 29 | 30 | org.springframework.boot 31 | 32 | spring-boot-starter-web 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-actuator 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | true 43 | 44 | 45 | org.projectlombok 46 | lombok 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | junit 55 | junit 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /cloud-eureka-server7001/src/main/java/com/yyb/springcloud/EurekaMain7001.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaMain7001 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(EurekaMain7001.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-eureka-server7001/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7001 3 | eureka: 4 | instance: 5 | hostname: eureka7001.com #eureka服务端的实例名字 6 | client: 7 | register-with-eureka: false #表示不向注册中心注册自己 8 | fetch-registry: false #表示自己就是注册中心,职责是维护服务实例,并不需要去检索服务 9 | service-url: 10 | # 单机版 11 | defaultZone: http://eureka7001.com:7001/eureka/ #设置与eureka server交互的地址查询服务和注册服务都需要依赖这个地址 12 | # 集群版 13 | # defaultZone: http://eureka7002.com:7002/eureka/ #设置与eureka server交互的地址查询服务和注册服务都需要依赖这个地址 14 | # server: 15 | # 是否开启自我保护模式,默认为开启(true),开启自我保护模式,EurekaServer不会立即将中断的EurekaClient从列表中清除。 16 | # enable-self-preservation: false 17 | # eviction-interval-timer-in-ms: 2000 18 | 19 | -------------------------------------------------------------------------------- /cloud-eureka-server7002/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-eureka-server7002 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-netflix-eureka-server 22 | 23 | 24 | com.yyb 25 | cloud-api-commons 26 | ${project.version} 27 | 28 | 29 | org.springframework.boot 30 | 31 | spring-boot-starter-web 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-actuator 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-devtools 40 | runtime 41 | true 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | junit 54 | junit 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /cloud-eureka-server7002/src/main/java/com/yyb/springcloud/EurekaMain7002.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaMain7002 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(EurekaMain7002.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-eureka-server7002/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7002 3 | eureka: 4 | instance: 5 | hostname: eureka7002.com #eureka服务端的实例名字 6 | client: 7 | register-with-eureka: false #表示不向注册中心注册自己 8 | fetch-registry: false #表示自己就是注册中心,职责是维护服务实例,并不需要去检索服务 9 | service-url: 10 | defaultZone: http://eureka7003.com:7003/eureka/ #设置与eureka server交互的地址查询服务和注册服务都需要依赖这个地址 11 | -------------------------------------------------------------------------------- /cloud-eureka-server7003/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-eureka-server7003 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-netflix-eureka-server 22 | 23 | 24 | com.yyb 25 | cloud-api-commons 26 | ${project.version} 27 | 28 | 29 | org.springframework.boot 30 | 31 | spring-boot-starter-web 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-actuator 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-devtools 40 | runtime 41 | true 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | junit 54 | junit 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /cloud-eureka-server7003/src/main/java/com/yyb/springcloud/EurekaMain7003.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaMain7003 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(EurekaMain7003.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-eureka-server7003/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7003 3 | eureka: 4 | instance: 5 | hostname: eureka7003.com #eureka服务端的实例名字 6 | client: 7 | register-with-eureka: false #表示不向注册中心注册自己 8 | fetch-registry: false #表示自己就是注册中心,职责是维护服务实例,并不需要去检索服务 9 | service-url: 10 | defaultZone: http://eureka7001.com:7001/eureka/ #设置与eureka server交互的地址查询服务和注册服务都需要依赖这个地址 11 | -------------------------------------------------------------------------------- /cloud-gateway9527/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-gateway9527 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-gateway 23 | 24 | 25 | com.yyb 26 | cloud-api-commons 27 | 1.0-SNAPSHOT 28 | compile 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter-netflix-hystrix 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-client 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | true 43 | 44 | 45 | org.projectlombok 46 | lombok 47 | true 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | test 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /cloud-gateway9527/src/main/java/com/yyb/springcloud/GatewayMain9527.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | public class GatewayMain9527 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(GatewayMain9527.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-gateway9527/src/main/java/com/yyb/springcloud/config/MyLogGatewayFilter.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.config; 2 | 3 | import org.springframework.cloud.gateway.filter.GatewayFilterChain; 4 | import org.springframework.cloud.gateway.filter.GlobalFilter; 5 | import org.springframework.core.Ordered; 6 | import org.springframework.web.server.ServerWebExchange; 7 | import reactor.core.publisher.Mono; 8 | 9 | public class MyLogGatewayFilter implements GlobalFilter, Ordered { 10 | 11 | @Override 12 | public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { 13 | return null; 14 | } 15 | 16 | @Override 17 | public int getOrder() { 18 | return 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cloud-gateway9527/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9527 3 | spring: 4 | application: 5 | name: cloud-gateway9527 6 | cloud: 7 | gateway: 8 | discovery: 9 | locator: 10 | enabled: true # 开启动态路由 11 | routes: 12 | - id: payment_routh #路由的ID,没有固定规则但要求唯一,建议配合服务名 13 | # uri: http://localhost:8001 #匹配后提供服务的路由地址 14 | uri: lb://cloud-payment-service #匹配后提供服务的路由地址 15 | predicates: 16 | - Path=/payment/** #断言,路径相匹配的进行路由 17 | 18 | - id: payment_routh2 19 | # uri: http://localhost:8001 20 | uri: lb://cloud-payment-service 21 | # filters: 22 | # - AddRequestParameter=X-Request-Id,1024 23 | predicates: 24 | - Path=/test/** #断言,路径相匹配的进行路由 25 | - After=2021-12-01T21:47:47.278138300+08:00[Asia/Shanghai] 26 | - Before=2021-12-31T21:47:47.278138300+08:00[Asia/Shanghai] 27 | # - Between=2021-12-01T21:47:47.278138300+08:00[Asia/Shanghai],2021-12-31T21:47:47.278138300+08:00[Asia/Shanghai] 28 | # - Cookie=username,xxyy 29 | # - Header=X-Request-Id 30 | # - Host= 31 | # - Method=POST 32 | # - Query= 33 | 34 | eureka: 35 | instance: 36 | hostname: cloud-gateway-service 37 | client: 38 | register-with-eureka: true 39 | fetch-registry: true 40 | service-url: 41 | # defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 42 | defaultZone: http://eureka7001.com:7001/eureka/ 43 | -------------------------------------------------------------------------------- /cloud-gateway9527/src/test/java/Test.java: -------------------------------------------------------------------------------- 1 | import java.time.ZonedDateTime; 2 | import java.util.function.Predicate; 3 | 4 | public class Test { 5 | public static void main(String[] args) { 6 | 7 | ZonedDateTime now = ZonedDateTime.now(); 8 | System.out.println(now); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /cloud-provider-hystrix-payment8001/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-provider-hystrix-payment8001 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | org.mybatis.spring.boot 30 | mybatis-spring-boot-starter 31 | 32 | 33 | com.alibaba 34 | druid-spring-boot-starter 35 | 1.1.10 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-jdbc 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-devtools 48 | runtime 49 | true 50 | 51 | 52 | org.projectlombok 53 | lombok 54 | true 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | 60 | 61 | com.yyb 62 | cloud-api-commons 63 | 1.0-SNAPSHOT 64 | compile 65 | 66 | 67 | org.springframework.cloud 68 | spring-cloud-starter-netflix-eureka-client 69 | 70 | 71 | org.springframework.cloud 72 | spring-cloud-starter-netflix-hystrix 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /cloud-provider-hystrix-payment8001/src/main/java/com/yyb/springcloud/PaymentHystrixMain8001.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 9 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 10 | import org.springframework.context.annotation.Bean; 11 | 12 | @SpringBootApplication 13 | @EnableEurekaClient 14 | @EnableDiscoveryClient 15 | @EnableHystrix 16 | public class PaymentHystrixMain8001 { 17 | public static void main(String[] args) { 18 | SpringApplication.run(PaymentHystrixMain8001.class, args); 19 | } 20 | 21 | @Bean 22 | public ServletRegistrationBean getServlet() { 23 | HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); 24 | ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); 25 | registrationBean.setLoadOnStartup(1); 26 | registrationBean.addUrlMappings("/hystrix.stream"); 27 | registrationBean.setName("HystrixMetricsStreamServlet"); 28 | return registrationBean; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /cloud-provider-hystrix-payment8001/src/main/java/com/yyb/springcloud/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.yyb.springcloud.service.PaymentService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.cloud.client.discovery.DiscoveryClient; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | 11 | @RestController 12 | @RequestMapping("/payment") 13 | @Slf4j 14 | public class PaymentController { 15 | @Resource 16 | private PaymentService paymentService; 17 | 18 | @Resource 19 | private DiscoveryClient discoveryClient; //注意要引入spring的包 20 | 21 | @Value("${server.port}") 22 | private String serverPort; 23 | 24 | 25 | @GetMapping("/paymentOk/{id}") 26 | public String paymentOk(@PathVariable("id") int id) { 27 | return paymentService.paymentOk(id); 28 | } 29 | 30 | // 服务降级 31 | @GetMapping("/paymentTimeout/{id}") 32 | public String paymentTimeout(@PathVariable("id") int id) { 33 | return paymentService.paymentTimeout(id); 34 | } 35 | 36 | // 服务熔断 37 | @GetMapping("/paymentBreaker/{id}") 38 | public String paymentBreaker(@PathVariable("id") int id) { 39 | return paymentService.paymentBreaker(id); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cloud-provider-hystrix-payment8001/src/main/java/com/yyb/springcloud/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service; 2 | 3 | 4 | public interface PaymentService { 5 | 6 | String paymentOk(int id); 7 | 8 | String paymentTimeout(int id); 9 | 10 | String paymentBreaker(int id); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /cloud-provider-hystrix-payment8001/src/main/java/com/yyb/springcloud/service/impl/PaymentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service.impl; 2 | 3 | import cn.hutool.core.util.IdUtil; 4 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 5 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; 6 | import com.yyb.springcloud.service.PaymentService; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.concurrent.TimeUnit; 10 | 11 | @Service 12 | public class PaymentServiceImpl implements PaymentService { 13 | 14 | @Override 15 | public String paymentOk(int id) { 16 | return "线程池:" + Thread.currentThread().getName() + "--OK--" + id; 17 | } 18 | 19 | @Override 20 | @HystrixCommand(fallbackMethod = "paymentTimeoutHandle", commandProperties = { 21 | @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "4000") 22 | }) 23 | public String paymentTimeout(int id) { 24 | // int i = 10 / 0; 25 | int timeOut = 5; 26 | try { 27 | TimeUnit.SECONDS.sleep(timeOut); 28 | } catch (InterruptedException e) { 29 | e.printStackTrace(); 30 | } 31 | return "线程池:" + Thread.currentThread().getName() + "--Timeout--" + id; 32 | } 33 | 34 | // 服务降级 35 | public String paymentTimeoutHandle(int id) { 36 | return "线程池:" + Thread.currentThread().getName() + "--服务出错--" + id; 37 | } 38 | 39 | // 服务熔断 40 | @Override 41 | @HystrixCommand(fallbackMethod = "paymentBreakerFallback", commandProperties = { 42 | @HystrixProperty(name = "circuitBreaker.enabled", value = "true"), 43 | @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "10"), 44 | @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000"), 45 | @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "60") 46 | }) 47 | public String paymentBreaker(int id) { 48 | if (id < 0) { 49 | throw new RuntimeException("id不能为负数"); // 出现异常,调用服务降级方法 50 | // return "主方法:id不能为负数"; 51 | } 52 | String s = IdUtil.simpleUUID(); 53 | return Thread.currentThread().getName() + "\t" + s; 54 | } 55 | 56 | public String paymentBreakerFallback(int id) { 57 | return "id不能为负数,请稍后再试"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /cloud-provider-hystrix-payment8001/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8001 3 | spring: 4 | application: 5 | name: cloud-payment-hystrix-service 6 | datasource: 7 | type: com.alibaba.druid.pool.DruidDataSource 8 | driver-class-name: org.gjt.mm.mysql.Driver 9 | url: jdbc:mysql://localhost:3306/springcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 10 | username: root 11 | password: root 12 | eureka: 13 | client: 14 | register-with-eureka: true 15 | fetch-registry: true 16 | service-url: 17 | # defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 18 | defaultZone: http://eureka7001.com:7001/eureka/ 19 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-provider-payment8001 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-actuator 28 | 29 | 30 | org.mybatis.spring.boot 31 | mybatis-spring-boot-starter 32 | 33 | 34 | com.alibaba 35 | druid-spring-boot-starter 36 | 1.1.10 37 | 38 | 39 | mysql 40 | mysql-connector-java 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-jdbc 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-devtools 49 | runtime 50 | true 51 | 52 | 53 | org.projectlombok 54 | lombok 55 | true 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | 61 | 62 | com.yyb 63 | cloud-api-commons 64 | 1.0-SNAPSHOT 65 | compile 66 | 67 | 68 | org.springframework.cloud 69 | spring-cloud-starter-netflix-eureka-client 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/java/com/yyb/springcloud/PaymentMain8001.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 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.netflix.eureka.EnableEurekaClient; 7 | 8 | @SpringBootApplication 9 | @EnableEurekaClient 10 | @EnableDiscoveryClient 11 | public class PaymentMain8001 { 12 | public static void main(String[] args) { 13 | SpringApplication.run(PaymentMain8001.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/java/com/yyb/springcloud/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.yyb.springcloud.entity.CommonResult; 4 | import com.yyb.springcloud.entity.Payment; 5 | import com.yyb.springcloud.service.PaymentService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.cloud.client.ServiceInstance; 9 | import org.springframework.cloud.client.discovery.DiscoveryClient; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | import java.util.concurrent.TimeUnit; 15 | 16 | @RestController 17 | @RequestMapping("/payment") 18 | @Slf4j 19 | public class PaymentController { 20 | @Resource 21 | private PaymentService paymentService; 22 | 23 | @Resource 24 | private DiscoveryClient discoveryClient; //注意要引入spring的包 25 | 26 | @Value("${server.port}") 27 | private String serverPort; 28 | 29 | @PostMapping("/addPayment") 30 | public CommonResult addPayment(@RequestBody Payment payment) { 31 | int i = paymentService.addPayment(payment); 32 | if (i > 0) { 33 | return new CommonResult(200, "添加成功,端口号:" + serverPort); 34 | } else { 35 | return new CommonResult(500, "添加失败"); 36 | 37 | } 38 | } 39 | 40 | @GetMapping("/getPaymentById/{id}") 41 | public CommonResult getPaymentById(@PathVariable("id") Long id) { 42 | Payment payment = paymentService.getPaymentById(id); 43 | if (payment != null) { 44 | return new CommonResult(200, "查询成功,端口号:" + serverPort, payment); 45 | } else { 46 | return new CommonResult(500, "查询失败"); 47 | } 48 | } 49 | 50 | @GetMapping("/discovery") 51 | public Object discovery() { 52 | List services = discoveryClient.getServices(); 53 | for (String service : services) { 54 | 55 | log.info(service); 56 | } 57 | List instances = discoveryClient.getInstances("CLOUD-PAYMENT-SERVICE"); 58 | for (ServiceInstance instance : instances) { 59 | log.info(instance.getServiceId() + "\n" + instance.getHost() + "\n" + instance.getPort()); 60 | } 61 | 62 | return this.discoveryClient; 63 | } 64 | 65 | @GetMapping("/timeout") 66 | public String timeout() { 67 | try { 68 | TimeUnit.SECONDS.sleep(3); 69 | } catch (InterruptedException e) { 70 | e.printStackTrace(); 71 | } 72 | return serverPort; 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/java/com/yyb/springcloud/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.web.bind.annotation.*; 5 | 6 | @RestController 7 | @RequestMapping("/test") 8 | @Slf4j 9 | public class TestController { 10 | 11 | @GetMapping("/get") 12 | public String get() { 13 | return "get方法"; 14 | } 15 | 16 | 17 | @GetMapping("/put") 18 | public String put() { 19 | return "put方法"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/java/com/yyb/springcloud/dao/PaymentDao.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.dao; 2 | 3 | import com.yyb.springcloud.entity.Payment; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | @Mapper 8 | public interface PaymentDao { 9 | 10 | public int addPayment(Payment payment); 11 | 12 | public Payment getPaymentById(@Param("id") Long id); 13 | } 14 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/java/com/yyb/springcloud/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service; 2 | 3 | import com.yyb.springcloud.entity.Payment; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface PaymentService { 7 | 8 | public int addPayment(Payment payment); 9 | 10 | public Payment getPaymentById(Long id); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/java/com/yyb/springcloud/service/impl/PaymentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service.impl; 2 | 3 | import com.yyb.springcloud.dao.PaymentDao; 4 | import com.yyb.springcloud.entity.Payment; 5 | import com.yyb.springcloud.service.PaymentService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | 11 | @Service 12 | public class PaymentServiceImpl implements PaymentService { 13 | @Resource 14 | // @Autowired 15 | private PaymentDao paymentDao; 16 | 17 | @Override 18 | public int addPayment(Payment payment) { 19 | return paymentDao.addPayment(payment); 20 | } 21 | 22 | @Override 23 | public Payment getPaymentById(Long id) { 24 | return paymentDao.getPaymentById(id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8001 3 | spring: 4 | application: 5 | name: cloud-payment-service 6 | datasource: 7 | type: com.alibaba.druid.pool.DruidDataSource 8 | driver-class-name: org.gjt.mm.mysql.Driver 9 | url: jdbc:mysql://localhost:3306/springcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 10 | username: root 11 | password: root 12 | mybatis: 13 | mapperLocations: classpath:mapper/*.xml 14 | type-aliases-package: com.yyb.springcloud.entity 15 | 16 | eureka: 17 | client: 18 | register-with-eureka: true 19 | fetch-registry: true 20 | service-url: 21 | defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 22 | instance: 23 | instance-id: payment8001 24 | prefer-ip-address: true 25 | # 发送心跳时间间隔 26 | lease-renewal-interval-in-seconds: 1 27 | lease-expiration-duration-in-seconds: 2 28 | -------------------------------------------------------------------------------- /cloud-provider-payment8001/src/main/resources/mapper/PaymentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | insert into payment(serial) 6 | values (#{serial}); 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-provider-payment8002 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-actuator 28 | 29 | 30 | org.mybatis.spring.boot 31 | mybatis-spring-boot-starter 32 | 33 | 34 | com.alibaba 35 | druid-spring-boot-starter 36 | 1.1.10 37 | 38 | 39 | mysql 40 | mysql-connector-java 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-jdbc 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-devtools 49 | runtime 50 | true 51 | 52 | 53 | org.projectlombok 54 | lombok 55 | true 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | 61 | 62 | com.yyb 63 | cloud-api-commons 64 | 1.0-SNAPSHOT 65 | compile 66 | 67 | 68 | org.springframework.cloud 69 | spring-cloud-starter-netflix-eureka-client 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/java/com/yyb/springcloud/PaymentMain8002.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 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.netflix.eureka.EnableEurekaClient; 7 | 8 | @SpringBootApplication 9 | @EnableEurekaClient 10 | @EnableDiscoveryClient 11 | public class PaymentMain8002 { 12 | public static void main(String[] args) { 13 | SpringApplication.run(PaymentMain8002.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/java/com/yyb/springcloud/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import com.yyb.springcloud.entity.CommonResult; 4 | import com.yyb.springcloud.entity.Payment; 5 | import com.yyb.springcloud.service.PaymentService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.cloud.client.ServiceInstance; 9 | import org.springframework.cloud.client.discovery.DiscoveryClient; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @RestController 16 | @RequestMapping("/payment") 17 | @Slf4j 18 | public class PaymentController { 19 | @Resource 20 | private PaymentService paymentService; 21 | 22 | @Resource 23 | private DiscoveryClient discoveryClient; 24 | 25 | @Value("${server.port}") 26 | private String serverPort; 27 | 28 | @PostMapping("/addPayment") 29 | public CommonResult addPayment(@RequestBody Payment payment) { 30 | int i = paymentService.addPayment(payment); 31 | if (i > 0) { 32 | return new CommonResult(200, "添加成功,端口号:" + serverPort); 33 | } else { 34 | return new CommonResult(500, "添加失败"); 35 | 36 | } 37 | } 38 | 39 | @GetMapping("/getPaymentById/{id}") 40 | public CommonResult getPaymentById(@PathVariable("id") Long id) { 41 | Payment payment = paymentService.getPaymentById(id); 42 | if (payment != null) { 43 | return new CommonResult(200, "查询成功,端口号:" + serverPort, payment); 44 | } else { 45 | return new CommonResult(500, "查询失败"); 46 | } 47 | } 48 | 49 | @GetMapping("/discovery") 50 | public Object discovery() { 51 | 52 | List services = discoveryClient.getServices(); 53 | for (String service : services) { 54 | log.info(service); 55 | } 56 | List instances = this.discoveryClient.getInstances("CLOUD-PAYMENT-SERVICE"); 57 | for (ServiceInstance instance : instances) { 58 | log.info("\n" + instance.getServiceId() + "\t" + instance.getHost() + "\t" + instance.getPort()); 59 | } 60 | return this.discoveryClient; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/java/com/yyb/springcloud/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | @RequestMapping("/test") 10 | @Slf4j 11 | public class TestController { 12 | 13 | @GetMapping("/get") 14 | public String get() { 15 | return "get方法"; 16 | } 17 | 18 | 19 | @GetMapping("/put") 20 | public String put() { 21 | return "put方法"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/java/com/yyb/springcloud/dao/PaymentDao.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.dao; 2 | 3 | import com.yyb.springcloud.entity.Payment; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | @Mapper 8 | public interface PaymentDao { 9 | 10 | public int addPayment(Payment payment); 11 | 12 | public Payment getPaymentById(@Param("id") Long id); 13 | } 14 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/java/com/yyb/springcloud/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service; 2 | 3 | import com.yyb.springcloud.entity.Payment; 4 | 5 | public interface PaymentService { 6 | 7 | public int addPayment(Payment payment); 8 | 9 | public Payment getPaymentById(Long id); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/java/com/yyb/springcloud/service/impl/PaymentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service.impl; 2 | 3 | import com.yyb.springcloud.dao.PaymentDao; 4 | import com.yyb.springcloud.entity.Payment; 5 | import com.yyb.springcloud.service.PaymentService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @Service 11 | public class PaymentServiceImpl implements PaymentService { 12 | @Resource 13 | // @Autowired 14 | private PaymentDao paymentDao; 15 | 16 | @Override 17 | public int addPayment(Payment payment) { 18 | return paymentDao.addPayment(payment); 19 | } 20 | 21 | @Override 22 | public Payment getPaymentById(Long id) { 23 | return paymentDao.getPaymentById(id); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8002 3 | spring: 4 | application: 5 | name: cloud-payment-service 6 | datasource: 7 | type: com.alibaba.druid.pool.DruidDataSource 8 | driver-class-name: org.gjt.mm.mysql.Driver 9 | url: jdbc:mysql://localhost:3306/springcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 10 | username: root 11 | password: root 12 | mybatis: 13 | mapperLocations: classpath:mapper/*.xml 14 | type-aliases-package: com.yyb.springcloud.entity 15 | 16 | eureka: 17 | client: 18 | register-with-eureka: true 19 | fetch-registry: true 20 | service-url: 21 | defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ 22 | instance: 23 | instance-id: payment8002 24 | prefer-ip-address: true 25 | -------------------------------------------------------------------------------- /cloud-provider-payment8002/src/main/resources/mapper/PaymentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | insert into payment(serial) 6 | values (#{serial}); 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | springcloud 7 | com.yyb 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | cloud-provider-payment8004 13 | 14 | 15 | 11 16 | 11 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | org.mybatis.spring.boot 30 | mybatis-spring-boot-starter 31 | 32 | 33 | com.alibaba 34 | druid-spring-boot-starter 35 | 1.1.10 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-jdbc 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-devtools 48 | runtime 49 | true 50 | 51 | 52 | org.projectlombok 53 | lombok 54 | true 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | 60 | 61 | com.yyb 62 | cloud-api-commons 63 | 1.0-SNAPSHOT 64 | compile 65 | 66 | 67 | org.springframework.cloud 68 | spring-cloud-starter-zookeeper-discovery 69 | 70 | 71 | 72 | org.apache.zookeeper 73 | zookeeper 74 | 75 | 76 | 77 | 78 | 79 | org.apache.zookeeper 80 | zookeeper 81 | 3.4.13 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/src/main/java/com/yyb/springcloud/PaymentZkMain8004.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class PaymentZkMain8004 { 10 | public static void main(String[] args) { 11 | SpringApplication.run(PaymentZkMain8004.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/src/main/java/com/yyb/springcloud/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.controller; 2 | 3 | import cn.hutool.core.lang.UUID; 4 | import com.yyb.springcloud.entity.CommonResult; 5 | import com.yyb.springcloud.entity.Payment; 6 | import com.yyb.springcloud.service.PaymentService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.cloud.client.ServiceInstance; 10 | import org.springframework.cloud.client.discovery.DiscoveryClient; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RestController 17 | @RequestMapping("/payment") 18 | @Slf4j 19 | public class PaymentController { 20 | @Resource 21 | private PaymentService paymentService; 22 | 23 | @Resource 24 | private DiscoveryClient discoveryClient; 25 | 26 | @Value("${server.port}") 27 | private String serverPort; 28 | 29 | @PostMapping("/addPayment") 30 | public CommonResult addPayment(@RequestBody Payment payment) { 31 | int i = paymentService.addPayment(payment); 32 | if (i > 0) { 33 | return new CommonResult(200, "添加成功,端口号:" + serverPort); 34 | } else { 35 | return new CommonResult(500, "添加失败"); 36 | 37 | } 38 | } 39 | 40 | @GetMapping("/getPaymentById/{id}") 41 | public CommonResult getPaymentById(@PathVariable("id") Long id) { 42 | Payment payment = paymentService.getPaymentById(id); 43 | if (payment != null) { 44 | return new CommonResult(200, "查询成功,端口号:" + serverPort, payment); 45 | } else { 46 | return new CommonResult(500, "查询失败"); 47 | } 48 | } 49 | 50 | @GetMapping("/discovery") 51 | public Object discovery() { 52 | 53 | List services = discoveryClient.getServices(); 54 | for (String service : services) { 55 | log.info(service); 56 | } 57 | List instances = this.discoveryClient.getInstances("CLOUD-PAYMENT-SERVICE"); 58 | for (ServiceInstance instance : instances) { 59 | log.info("\n" + instance.getServiceId() + "\t" + instance.getHost() + "\t" + instance.getPort()); 60 | } 61 | return this.discoveryClient; 62 | } 63 | 64 | @GetMapping("/getZk") 65 | public String getZk() { 66 | 67 | return "zookeeper:" + serverPort + "\t" + UUID.randomUUID().toString(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/src/main/java/com/yyb/springcloud/dao/PaymentDao.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.dao; 2 | 3 | import com.yyb.springcloud.entity.Payment; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | @Mapper 8 | public interface PaymentDao { 9 | 10 | public int addPayment(Payment payment); 11 | 12 | public Payment getPaymentById(@Param("id") Long id); 13 | } 14 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/src/main/java/com/yyb/springcloud/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service; 2 | 3 | import com.yyb.springcloud.entity.Payment; 4 | 5 | public interface PaymentService { 6 | 7 | public int addPayment(Payment payment); 8 | 9 | public Payment getPaymentById(Long id); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/src/main/java/com/yyb/springcloud/service/impl/PaymentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyb.springcloud.service.impl; 2 | 3 | import com.yyb.springcloud.dao.PaymentDao; 4 | import com.yyb.springcloud.entity.Payment; 5 | import com.yyb.springcloud.service.PaymentService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @Service 11 | public class PaymentServiceImpl implements PaymentService { 12 | @Resource 13 | // @Autowired 14 | private PaymentDao paymentDao; 15 | 16 | @Override 17 | public int addPayment(Payment payment) { 18 | return paymentDao.addPayment(payment); 19 | } 20 | 21 | @Override 22 | public Payment getPaymentById(Long id) { 23 | return paymentDao.getPaymentById(id); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cloud-provider-payment8004/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8004 3 | spring: 4 | application: 5 | name: cloud-payment-service 6 | datasource: 7 | type: com.alibaba.druid.pool.DruidDataSource 8 | driver-class-name: org.gjt.mm.mysql.Driver 9 | url: jdbc:mysql://localhost:3306/springcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 10 | username: root 11 | password: root 12 | cloud: 13 | zookeeper: 14 | discovery: 15 | enabled: true 16 | connect-string: localhost:2181 17 | mybatis: 18 | mapperLocations: classpath:mapper/*.xml 19 | type-aliases-package: com.yyb.springcloud.entity 20 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | com.yyb 8 | springcloud 9 | 1.0-SNAPSHOT 10 | 11 | cloud-provider-payment8001 12 | cloud-consumer-order80 13 | cloud-api-commons 14 | cloud-eureka-server7001 15 | cloud-eureka-server7002 16 | cloud-eureka-server7003 17 | cloud-provider-payment8002 18 | cloud-provider-payment8004 19 | cloud-consumerZK-order80 20 | cloud-consumer-feign-order80 21 | cloud-provider-hystrix-payment8001 22 | cloud-consumer-feign-hystrix-order80 23 | cloud-consumer-hystrix-dashborad-order9001 24 | cloud-gateway9527 25 | cloud-config-center3344 26 | cloud-config-client3355 27 | cloud-config-client3366 28 | alibaba-provider-payment9001 29 | alibaba-provider-payment90012 30 | alibaba-provider-payment9002 31 | 32 | pom 33 | 34 | 35 | UTF-8 36 | 1.8 37 | 1.8 38 | 4.12 39 | 1.2.17 40 | 1.18.16 41 | 5.1.47 42 | 1.1.16 43 | 1.3.0 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-dependencies 51 | 2.2.2.RELEASE 52 | pom 53 | import 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-dependencies 58 | Hoxton.SR1 59 | pom 60 | import 61 | 62 | 63 | 64 | com.alibaba.cloud 65 | spring-cloud-alibaba-dependencies 66 | 2.1.0.RELEASE 67 | pom 68 | import 69 | 70 | 71 | 72 | mysql 73 | mysql-connector-java 74 | ${mysql.version} 75 | 76 | 77 | 78 | com.alibaba 79 | druid 80 | ${druid.version} 81 | 82 | 83 | org.mybatis.spring.boot 84 | mybatis-spring-boot-starter 85 | ${mybatis.spring.boot.version} 86 | 87 | 88 | 89 | junit 90 | junit 91 | ${junit.version} 92 | 93 | 94 | 95 | log4j 96 | log4j 97 | ${log4j.version} 98 | 99 | 100 | 101 | org.projectlombok 102 | lombok 103 | ${lombok.version} 104 | true 105 | 106 | 107 | com.alibaba.cloud 108 | spring-cloud-alibaba-dependencies 109 | 2.1.0.RELEASE 110 | pom 111 | import 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | org.springframework.boot 120 | spring-boot-maven-plugin 121 | 122 | true 123 | true 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | --------------------------------------------------------------------------------