├── config ├── service-customer.yml ├── service-customer-docker.yml ├── service-customer-native.yml ├── service-customer-mysql-docker.yml ├── service-customer-mysql-native.yml ├── service-customer-redis-docker.yml └── service-customer-redis-native.yml ├── screenshots ├── Hystrix monitor.png ├── Spring boot admin detail.png ├── Spring boot admin wallboard.png └── Service customer hystrix stream.png ├── api-gateway ├── src │ └── main │ │ ├── resources │ │ ├── application-native.yml │ │ ├── application-docker.yml │ │ ├── banner.txt │ │ └── application.yml │ │ ├── docker │ │ └── Dockerfile │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── apigateway │ │ ├── ApiGatewayApplication.java │ │ └── config │ │ └── fallback │ │ └── CustomerFallback.java └── pom.xml ├── turbine-server ├── src │ └── main │ │ ├── resources │ │ ├── application-native.yml │ │ ├── application-docker.yml │ │ ├── application.yml │ │ └── banner.txt │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── turbine │ │ └── TurbineServerApplication.java └── pom.xml ├── zipkin-server ├── src │ └── main │ │ ├── resources │ │ ├── application-docker.yml │ │ ├── application-native.yml │ │ └── application.yml │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── zipkinserver │ │ └── ZipkinServerApplication.java └── pom.xml ├── service-producer ├── core │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── application-native.yml │ │ │ ├── application-docker.yml │ │ │ ├── application.yml │ │ │ └── banner.txt │ │ │ ├── docker │ │ │ └── Dockerfile │ │ │ └── java │ │ │ └── com │ │ │ └── qianlq │ │ │ └── core │ │ │ ├── service │ │ │ ├── TestService.java │ │ │ └── impl │ │ │ │ └── TestServiceImpl.java │ │ │ ├── ServiceProducerApplication.java │ │ │ ├── controller │ │ │ └── TestController.java │ │ │ └── config │ │ │ └── swagger │ │ │ └── Swagger2Config.java │ └── pom.xml ├── support │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── qianlq │ │ │ └── support │ │ │ └── client │ │ │ ├── hystrix │ │ │ └── HystrixClientFallBack.java │ │ │ └── TestClient.java │ └── pom.xml └── pom.xml ├── service-customer ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── qianlq │ │ │ │ └── customer │ │ │ │ ├── model │ │ │ │ ├── entity │ │ │ │ │ ├── BaseEntity.java │ │ │ │ │ └── UserEntity.java │ │ │ │ └── dto │ │ │ │ │ └── UserDto.java │ │ │ │ ├── common │ │ │ │ ├── exception │ │ │ │ │ ├── BusinessException.java │ │ │ │ │ ├── BaseException.java │ │ │ │ │ └── GlobalExceptionHandlerAdvice.java │ │ │ │ ├── message │ │ │ │ │ ├── Consumer.java │ │ │ │ │ ├── Producer.java │ │ │ │ │ └── Channel.java │ │ │ │ ├── BaseResultFactory.java │ │ │ │ ├── BaseResult.java │ │ │ │ └── constant │ │ │ │ │ └── Code.java │ │ │ │ ├── converter │ │ │ │ └── User2UserDtoMapper.java │ │ │ │ ├── config │ │ │ │ ├── HystrixConfig.java │ │ │ │ ├── FeignBeanFactoryPostProcessor.java │ │ │ │ ├── swagger │ │ │ │ │ └── Swagger2Config.java │ │ │ │ └── interceptors │ │ │ │ │ └── WebAppConfigurer.java │ │ │ │ ├── service │ │ │ │ ├── TestService.java │ │ │ │ └── impl │ │ │ │ │ └── TestServiceImpl.java │ │ │ │ ├── ServiceCustomerApplication.java │ │ │ │ ├── interceptor │ │ │ │ ├── MonitorInterceptor.java │ │ │ │ └── log │ │ │ │ │ └── ServiceLogAOP.java │ │ │ │ └── controller │ │ │ │ └── TestController.java │ │ ├── resources │ │ │ ├── bootstrap-native.yml │ │ │ ├── bootstrap-docker.yml │ │ │ ├── banner.txt │ │ │ ├── bootstrap.yml │ │ │ └── log4j2.xml │ │ └── docker │ │ │ └── Dockerfile │ └── test │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── customer │ │ ├── SpringCustomerApplicationTests.java │ │ ├── config │ │ └── ConfigTest.java │ │ └── service │ │ └── TestServiceTest.java └── pom.xml ├── config-server ├── src │ └── main │ │ ├── resources │ │ ├── application-native.yml │ │ ├── application-docker.yml │ │ ├── application.yml │ │ └── banner.txt │ │ ├── docker │ │ └── Dockerfile │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── config │ │ └── ConfigServerApplication.java └── pom.xml ├── eureka-server ├── src │ └── main │ │ ├── resources │ │ ├── application-native.yml │ │ ├── application-docker.yml │ │ ├── banner.txt │ │ └── application.yml │ │ ├── docker │ │ └── Dockerfile │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── eureka │ │ └── EurekaServerApplication.java └── pom.xml ├── hystrix-dashboard ├── src │ └── main │ │ ├── resources │ │ ├── application-native.yml │ │ ├── application.yml │ │ ├── application-docker.yml │ │ └── banner.txt │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── hystrix │ │ └── HystrixDashboardApplication.java └── pom.xml ├── .travis.yml ├── consul-server ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── qianlq │ │ └── consulserver │ │ ├── ConsulServerApplication.java │ │ └── controller │ │ └── ConsulController.java └── pom.xml ├── .gitignore ├── gateway-server ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── qianlq │ │ │ └── gateway │ │ │ ├── GatewayApplication.java │ │ │ └── controller │ │ │ └── FallbackController.java │ │ └── resources │ │ ├── banner.txt │ │ └── application.yml └── pom.xml ├── admin-dashboard ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── qianlq │ │ │ └── admin │ │ │ ├── AdminDashboardApplication.java │ │ │ └── config │ │ │ └── SecuritySecureConfig.java │ │ └── resources │ │ └── application.yml └── pom.xml ├── docker-compose.yml ├── LICENSE ├── README-zh.md ├── README.md └── pom.xml /config/service-customer.yml: -------------------------------------------------------------------------------- 1 | profile: default -------------------------------------------------------------------------------- /config/service-customer-docker.yml: -------------------------------------------------------------------------------- 1 | profile: docker 2 | -------------------------------------------------------------------------------- /config/service-customer-native.yml: -------------------------------------------------------------------------------- 1 | profile: native 2 | -------------------------------------------------------------------------------- /config/service-customer-mysql-docker.yml: -------------------------------------------------------------------------------- 1 | mysql: mysql-docker -------------------------------------------------------------------------------- /config/service-customer-mysql-native.yml: -------------------------------------------------------------------------------- 1 | mysql: mysql-native -------------------------------------------------------------------------------- /config/service-customer-redis-docker.yml: -------------------------------------------------------------------------------- 1 | redis: redis-docker -------------------------------------------------------------------------------- /config/service-customer-redis-native.yml: -------------------------------------------------------------------------------- 1 | redis: redis-native -------------------------------------------------------------------------------- /screenshots/Hystrix monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderqianlq/spring-cloud-learning/HEAD/screenshots/Hystrix monitor.png -------------------------------------------------------------------------------- /api-gateway/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ 5 | -------------------------------------------------------------------------------- /screenshots/Spring boot admin detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderqianlq/spring-cloud-learning/HEAD/screenshots/Spring boot admin detail.png -------------------------------------------------------------------------------- /turbine-server/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ -------------------------------------------------------------------------------- /zipkin-server/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://eureka-server:8761/eureka/ -------------------------------------------------------------------------------- /zipkin-server/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ -------------------------------------------------------------------------------- /api-gateway/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://eureka-server:8761/eureka/ 5 | -------------------------------------------------------------------------------- /screenshots/Spring boot admin wallboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderqianlq/spring-cloud-learning/HEAD/screenshots/Spring boot admin wallboard.png -------------------------------------------------------------------------------- /service-producer/core/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ -------------------------------------------------------------------------------- /turbine-server/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://eureka-server:8761/eureka/ -------------------------------------------------------------------------------- /screenshots/Service customer hystrix stream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderqianlq/spring-cloud-learning/HEAD/screenshots/Service customer hystrix stream.png -------------------------------------------------------------------------------- /service-producer/core/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://eureka-server:8761/eureka/ -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/model/entity/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.model.entity; 2 | 3 | public abstract class BaseEntity { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /config-server/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | hostname: localhost 4 | client: 5 | serviceUrl: 6 | defaultZone: http://localhost:8761/eureka/ -------------------------------------------------------------------------------- /eureka-server/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | hostname: localhost 4 | client: 5 | serviceUrl: 6 | defaultZone: http://localhost:8761/eureka/ -------------------------------------------------------------------------------- /zipkin-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9411 3 | 4 | spring: 5 | application: 6 | name: zipkin-server 7 | profiles: 8 | active: @profiles.active@ 9 | -------------------------------------------------------------------------------- /hystrix-dashboard/src/main/resources/application-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | hostname: localhost 4 | client: 5 | serviceUrl: 6 | defaultZone: http://localhost:8761/eureka/ -------------------------------------------------------------------------------- /config-server/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | hostname: config-server 4 | client: 5 | serviceUrl: 6 | defaultZone: http://eureka-server:8761/eureka/ -------------------------------------------------------------------------------- /hystrix-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8050 3 | 4 | spring: 5 | application: 6 | name: hystrix-dashboard 7 | profiles: 8 | active: @profiles.active@ 9 | -------------------------------------------------------------------------------- /eureka-server/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | hostname: eureka-server 4 | client: 5 | serviceUrl: 6 | defaultZone: http://eureka-server:8761/eureka/ 7 | -------------------------------------------------------------------------------- /hystrix-dashboard/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | hostname: hystrix-server 4 | client: 5 | serviceUrl: 6 | defaultZone: http://eureka-server:8761/eureka/ -------------------------------------------------------------------------------- /api-gateway/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD api-gateway-1.3.0-SNAPSHOT.jar api-gateway.jar 4 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/api-gateway.jar"] 5 | EXPOSE 9090 -------------------------------------------------------------------------------- /config-server/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD config-server-1.0.0-SNAPSHOT.jar config-server.jar 4 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/config-server.jar"] 5 | EXPOSE 8504 -------------------------------------------------------------------------------- /service-producer/core/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD service-producer-core-2.3.0-SNAPSHOT.jar service-producer.jar 4 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/service-producer.jar"] 5 | EXPOSE 8100 -------------------------------------------------------------------------------- /eureka-server/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | MAINTAINER qianlq "1242202279@qq.com" 3 | VOLUME /tmp 4 | COPY eureka-server-1.0.0-SNAPSHOT.jar eureka-server.jar 5 | ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom"] 6 | CMD ["-jar", "/eureka-server.jar"] 7 | EXPOSE 8761 -------------------------------------------------------------------------------- /service-producer/core/src/main/java/com/qianlq/core/service/TestService.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.core.service; 2 | 3 | public interface TestService { 4 | 5 | /** 6 | * 测试接口 7 | * 8 | * @param text 测试数据 9 | * @return String 10 | */ 11 | String test(String text); 12 | } 13 | -------------------------------------------------------------------------------- /service-customer/src/main/resources/bootstrap-native.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ 5 | 6 | spring: 7 | cloud: 8 | config: 9 | discovery: 10 | enabled: true 11 | service-id: config-server 12 | uri: http://localhost:8504/ 13 | fail-fast: true -------------------------------------------------------------------------------- /turbine-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8060 3 | 4 | spring: 5 | application: 6 | name: turbine-server 7 | 8 | turbine: 9 | app-config: service-producer,service-customer 10 | cluster-name-expression: new String("default") 11 | # 同一主机上的服务通过host和port的组合来进行区分, 默认使用host区分 12 | combine-host-port: true 13 | -------------------------------------------------------------------------------- /service-customer/src/main/resources/bootstrap-docker.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://eureka-server:8761/eureka/ 5 | 6 | spring: 7 | cloud: 8 | config: 9 | discovery: 10 | enabled: true 11 | service-id: config-server 12 | uri: http://config-server:8504/ 13 | fail-fast: true -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | jdk: 4 | - openjdk8 5 | 6 | branches: 7 | only: 8 | - master 9 | 10 | install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true 11 | script: mvn -DskipTests=true clean install 12 | 13 | after_success: 14 | - mvn clean test jacoco:report 15 | - mvn coveralls:report -DrepoToken="${RepoToken}" 16 | -------------------------------------------------------------------------------- /service-producer/core/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8100 3 | 4 | spring: 5 | application: 6 | name: service-producer 7 | profiles: 8 | active: @profiles.active@ 9 | 10 | management: 11 | endpoints: 12 | web: 13 | exposure: 14 | include: "*" 15 | endpoint: 16 | health: 17 | show-details: always -------------------------------------------------------------------------------- /consul-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=consul-server 2 | server.port=8502 3 | 4 | spring.cloud.consul.host=http://127.0.0.1 5 | spring.cloud.consul.port=8500 6 | 7 | spring.cloud.consul.discovery.health-check-path=/health 8 | spring.cloud.consul.discovery.health-check-interval=15s 9 | spring.cloud.consul.discovery.instance-id=consul-server 10 | 11 | -------------------------------------------------------------------------------- /service-producer/core/src/main/java/com/qianlq/core/service/impl/TestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.core.service.impl; 2 | 3 | import com.qianlq.core.service.TestService; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | public class TestServiceImpl implements TestService { 8 | 9 | @Override 10 | public String test(String text) { 11 | return text; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8504 3 | 4 | spring: 5 | application: 6 | name: config-server 7 | profiles: 8 | active: @profiles.active@ 9 | cloud: 10 | config: 11 | server: 12 | git: 13 | uri: https://github.com/coderqianlq/spring-cloud-learning.git 14 | search-paths: config 15 | # 如果代码仓库是公开的,则不需要设置用户名和密码 16 | username: 17 | password: 18 | -------------------------------------------------------------------------------- /service-producer/support/src/main/java/com/qianlq/support/client/hystrix/HystrixClientFallBack.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.support.client.hystrix; 2 | 3 | import com.qianlq.support.client.TestClient; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class HystrixClientFallBack implements TestClient { 8 | 9 | @Override 10 | public String test(String text) { 11 | return "服务调用失败: " + text; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /service-customer/src/test/java/com/qianlq/customer/SpringCustomerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @SpringBootTest 9 | @RunWith(SpringRunner.class) 10 | public class SpringCustomerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /.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/ 25 | 26 | .mvn/ 27 | mvnw 28 | mvnw.cmd 29 | 30 | ## idea 31 | idea/ 32 | *.iml 33 | 34 | */.DS_Store 35 | .DS_Store 36 | 37 | ## log 38 | logs 39 | *.log -------------------------------------------------------------------------------- /eureka-server/src/main/java/com/qianlq/eureka/EurekaServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @EnableEurekaServer 8 | @SpringBootApplication 9 | public class EurekaServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServerApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gateway-server/src/main/java/com/qianlq/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.gateway; 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 GatewayApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(GatewayApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gateway-server/src/main/java/com/qianlq/gateway/controller/FallbackController.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.gateway.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class FallbackController { 8 | 9 | private static final String FALLBACK_MESSAGE = "Service call failed"; 10 | 11 | @RequestMapping(value = "/fallback") 12 | public String fallback() { 13 | return FALLBACK_MESSAGE; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /config-server/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ██████╗ ██████╗ ███╗ ██╗███████╗██╗ ██████╗ 2 | ██╔════╝██╔═══██╗████╗ ██║██╔════╝██║██╔════╝ 3 | ██║ ██║ ██║██╔██╗ ██║█████╗ ██║██║ ███╗ 4 | ██║ ██║ ██║██║╚██╗██║██╔══╝ ██║██║ ██║ 5 | ╚██████╗╚██████╔╝██║ ╚████║██║ ██║╚██████╔╝ 6 | ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ 7 | ░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ▒ ░ ░▓ ░▒ ▒ 8 | ░ ▒ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ▒ ░ ░ ░ 9 | ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ 10 | ░ ░ ░ ░ ░ ░ ░ 11 | ░ -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.exception; 2 | 3 | import com.qianlq.customer.common.constant.Code; 4 | 5 | public final class BusinessException extends BaseException { 6 | 7 | public BusinessException() { 8 | this(Code.FAILED); 9 | } 10 | 11 | public BusinessException(Code code) { 12 | super(code.getCode(), code.getMsg()); 13 | } 14 | 15 | public BusinessException(String msg) { 16 | super(msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /consul-server/src/main/java/com/qianlq/consulserver/ConsulServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.consulserver; 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 ConsulServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConsulServerApplication.class, args); 13 | } 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /eureka-server/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ███████╗██╗ ██╗██████╗ ███████╗██╗ ██╗ █████╗ 2 | ██╔════╝██║ ██║██╔══██╗██╔════╝██║ ██╔╝██╔══██╗ 3 | █████╗ ██║ ██║██████╔╝█████╗ █████╔╝ ███████║ 4 | ██╔══╝ ██║ ██║██╔══██╗██╔══╝ ██╔═██╗ ██╔══██║ 5 | ███████╗╚██████╔╝██║ ██║███████╗██║ ██╗██║ ██║ 6 | ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ 7 | ░ ░▒ ▒ ░░ ▒░▒░▒░ ▒▒▓ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░░░ ▒▒░ ▒ 8 | ░ ▒ ░ ▒ ▒░ ░ ▒ ▒ ░ ░ ░ ░▒ ░ ▒░ ░ ▒░ ░ 9 | ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ 10 | ░ ░ ░ ░ ░ ░ ░ ░ ░ -------------------------------------------------------------------------------- /service-producer/core/src/main/java/com/qianlq/core/ServiceProducerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.core; 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 ServiceProducerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ServiceProducerApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /consul-server/src/main/java/com/qianlq/consulserver/controller/ConsulController.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.consulserver.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RequestMethod; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | @RequestMapping(value = "/") 9 | public class ConsulController { 10 | 11 | @RequestMapping(value = "/health", method = RequestMethod.GET) 12 | public String health() { 13 | return "health"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /eureka-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | spring: 5 | application: 6 | name: eureka-server 7 | profiles: 8 | # 不加单引号会报错 9 | active: '@profiles.active@' 10 | 11 | eureka: 12 | instance: 13 | prefer-ip-address: true 14 | instance-id: ${spring.application.name}:${server.port} 15 | client: 16 | # 表示是否将自己注册到Eureka Server上,默认为true 17 | register-with-eureka: false 18 | # 表示是否从Eureka Server上获取注册信息,默认为true 19 | fetch-registry: false 20 | server: 21 | # 自我保护机制 22 | enable-self-preservation: true 23 | 24 | -------------------------------------------------------------------------------- /hystrix-dashboard/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ██╗ ██╗██╗ ██╗███████╗████████╗██████╗ ██╗██╗ ██╗ 2 | ██║ ██║╚██╗ ██╔╝██╔════╝╚══██╔══╝██╔══██╗██║╚██╗██╔╝ 3 | ███████║ ╚████╔╝ ███████╗ ██║ ██████╔╝██║ ╚███╔╝ 4 | ██╔══██║ ╚██╔╝ ╚════██║ ██║ ██╔══██╗██║ ██╔██╗ 5 | ██║ ██║ ██║ ███████║ ██║ ██║ ██║██║██╔╝ ██╗ 6 | ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝ 7 | ▒ ░░▒░▒ ██▒▒▒ ▒ ▒▓▒ ▒ ░ ▒ ░░ ░ ▒▓ ░▒▓░░▓ ▒▒ ░ ░▓ 8 | ▒ ░▒░ ░▓██ ░▒░ ░ ░▒ ░ ░ ░ ░▒ ░ ▒░ ▒ ░░░ ░▒ 9 | ░ ░░ ░▒ ▒ ░░ ░ ░ ░ ░ ░░ ░ ▒ ░ ░ ░ 10 | ░ ░ ░░ ░ ░ ░ ░ ░ ░ 11 | ░ ░ 12 | -------------------------------------------------------------------------------- /zipkin-server/src/main/java/com/qianlq/zipkinserver/ZipkinServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.zipkinserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import zipkin2.server.internal.EnableZipkinServer; 7 | 8 | @EnableZipkinServer 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | public class ZipkinServerApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ZipkinServerApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/qianlq/apigateway/ApiGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.apigateway; 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.zuul.EnableZuulProxy; 7 | 8 | @EnableZuulProxy 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | public class ApiGatewayApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ApiGatewayApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /config-server/src/main/java/com/qianlq/config/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.config; 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 | @EnableConfigServer 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | public class ConfigServerApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ConfigServerApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /turbine-server/src/main/java/com/qianlq/turbine/TurbineServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.turbine; 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.turbine.EnableTurbine; 7 | 8 | @EnableTurbine 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | public class TurbineServerApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(TurbineServerApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /admin-dashboard/src/main/java/com/qianlq/admin/AdminDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.admin; 2 | 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | 8 | @EnableAdminServer 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | public class AdminDashboardApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(AdminDashboardApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /turbine-server/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ████████╗██╗ ██╗██████╗ ██████╗ ██╗███╗ ██╗███████╗ 2 | ╚══██╔══╝██║ ██║██╔══██╗██╔══██╗██║████╗ ██║██╔════╝ 3 | ██║ ██║ ██║██████╔╝██████╔╝██║██╔██╗ ██║█████╗ 4 | ██║ ██║ ██║██╔══██╗██╔══██╗██║██║╚██╗██║██╔══╝ 5 | ██║ ╚██████╔╝██║ ██║██████╔╝██║██║ ╚████║███████╗ 6 | ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ 7 | ▒ ░░ ░▒▓▒ ▒ ▒ ░ ▒▓ ░▒▓░░▒▓███▀▒░▓ ░ ▒░ ▒ ▒ ░░ ▒░ 8 | ░ ░░▒░ ░ ░ ░▒ ░ ▒░▒░▒ ░ ▒ ░░ ░░ ░ ▒░ ░ ░ 9 | ░ ░░░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ 10 | ░ ░ ░ ░ ░ ░ 11 | ░ 12 | -------------------------------------------------------------------------------- /api-gateway/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ██████╗ █████╗ ████████╗███████╗██╗ ██╗ █████╗ ██╗ ██╗ 2 | ██╔════╝ ██╔══██╗╚══██╔══╝██╔════╝██║ ██║██╔══██╗╚██╗ ██╔╝ 3 | ██║ ███╗███████║ ██║ █████╗ ██║ █╗ ██║███████║ ╚████╔╝ 4 | ██║ ██║██╔══██║ ██║ ██╔══╝ ██║███╗██║██╔══██║ ╚██╔╝ 5 | ╚██████╔╝██║ ██║ ██║ ███████╗╚███╔███╔╝██║ ██║ ██║ 6 | ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ 7 | ░ ░▒ ▒ ░░ ▒░▒░▒░ ▒▒▓ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░░░ ▒▒░ ▒ ░▓ ▒▒ ▓ 8 | ░ ▒ ░ ▒ ▒░ ░ ▒ ▒ ░ ░ ░ ░▒ ░ ▒░ ░ ▒░ ░ ▒ ░ ▒ ▒ 9 | ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░ 10 | ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/message/Consumer.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.message; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.springframework.cloud.stream.annotation.EnableBinding; 6 | import org.springframework.cloud.stream.annotation.StreamListener; 7 | 8 | @EnableBinding(Channel.class) 9 | public class Consumer { 10 | 11 | private final Logger LOGGER = LogManager.getLogger(Consumer.class); 12 | 13 | @StreamListener(Channel.CONSUMER) 14 | public void consume(String message) { 15 | LOGGER.info("接收消息: {}", message); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /gateway-server/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ██████╗ █████╗ ████████╗███████╗██╗ ██╗ █████╗ ██╗ ██╗ 2 | ██╔════╝ ██╔══██╗╚══██╔══╝██╔════╝██║ ██║██╔══██╗╚██╗ ██╔╝ 3 | ██║ ███╗███████║ ██║ █████╗ ██║ █╗ ██║███████║ ╚████╔╝ 4 | ██║ ██║██╔══██║ ██║ ██╔══╝ ██║███╗██║██╔══██║ ╚██╔╝ 5 | ╚██████╔╝██║ ██║ ██║ ███████╗╚███╔███╔╝██║ ██║ ██║ 6 | ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ 7 | ░ ░▒ ▒ ░░ ▒░▒░▒░ ▒▒▓ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░░░ ▒▒░ ▒ ░▓ ▒▒ ▓ 8 | ░ ▒ ░ ▒ ▒░ ░ ▒ ▒ ░ ░ ░ ░▒ ░ ▒░ ░ ▒░ ░ ▒ ░ ▒ ▒ 9 | ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░ 10 | ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ -------------------------------------------------------------------------------- /service-customer/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | 3 | ENV DOCKERIZE_VERSION v0.6.1 4 | RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 5 | && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 6 | && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz 7 | 8 | VOLUME /tmp 9 | ADD service-customer-2.1.0-SNAPSHOT.jar service-customer.jar 10 | ENTRYPOINT ["dockerize", "-timeout", "5m", "-wait", "http://config-server:8504/health", "java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/service-customer.jar"] 11 | EXPOSE 8200 -------------------------------------------------------------------------------- /hystrix-dashboard/src/main/java/com/qianlq/hystrix/HystrixDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.hystrix; 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.hystrix.dashboard.EnableHystrixDashboard; 7 | 8 | @EnableDiscoveryClient 9 | @EnableHystrixDashboard 10 | @SpringBootApplication 11 | public class HystrixDashboardApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(HystrixDashboardApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/BaseResultFactory.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common; 2 | 3 | import com.qianlq.customer.common.constant.Code; 4 | 5 | public class BaseResultFactory { 6 | 7 | /** 8 | * 构建成功并返回的数据 9 | * 10 | * @param data 返回数据 11 | * @return BaseResult 12 | */ 13 | public static BaseResult createSuccessResult(T data) { 14 | return new BaseResult<>(Code.SUCCESS, data); 15 | } 16 | 17 | /** 18 | * 成功但不返回的数据T 19 | * 20 | * @return BaseResult 21 | */ 22 | public static BaseResult createEmptyResult() { 23 | return new BaseResult<>(Code.SUCCESS); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /admin-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8040 3 | 4 | spring: 5 | application: 6 | name: admin-dashboard 7 | security: 8 | user: 9 | name: admin 10 | password: admin 11 | 12 | eureka: 13 | instance: 14 | lease-renewal-interval-in-seconds: 10 15 | metadata-map: 16 | user.name: ${spring.security.user.name} 17 | user.password: ${spring.security.user.password} 18 | client: 19 | registry-fetch-interval-seconds: 5 20 | serviceUrl: 21 | defaultZone: http://localhost:8761/eureka/ 22 | 23 | management: 24 | endpoints: 25 | web: 26 | exposure: 27 | include: "*" 28 | endpoint: 29 | health: 30 | show-details: always -------------------------------------------------------------------------------- /service-producer/core/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗███████╗██████╗ 2 | ██╔══██╗██╔══██╗██╔═══██╗██╔══██╗██║ ██║██╔════╝██╔════╝██╔══██╗ 3 | ██████╔╝██████╔╝██║ ██║██║ ██║██║ ██║██║ █████╗ ██████╔╝ 4 | ██╔═══╝ ██╔══██╗██║ ██║██║ ██║██║ ██║██║ ██╔══╝ ██╔══██╗ 5 | ██║ ██║ ██║╚██████╔╝██████╔╝╚██████╔╝╚██████╗███████╗██║ ██║ 6 | ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝╚══════╝╚═╝ ╚═╝ 7 | ░▒ ░ ░▒ ░ ▒░ ░ ▒ ▒░ ░ ▒ ▒ ░░▒░ ░ ░ ░ ▒ ░ ░ ░ ░▒ ░ 8 | ░░ ░░ ░ ░ ░ ░ ▒ ░ ░ ░ ░░░ ░ ░ ░ ░ ░░ 9 | ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ 10 | ░ ░ 11 | -------------------------------------------------------------------------------- /service-customer/src/test/java/com/qianlq/customer/config/ConfigTest.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.config; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @SpringBootTest 11 | @RunWith(SpringRunner.class) 12 | public class ConfigTest { 13 | 14 | @Value("${profile}") 15 | private String profile; 16 | 17 | @Test 18 | public void testConfig() { 19 | // 先启动config server, 在执行该测试方法, 否则会报错 20 | Assert.assertEquals("native", profile); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/model/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.model.dto; 2 | 3 | public class UserDto { 4 | 5 | private String id; 6 | 7 | private String name; 8 | 9 | private String birth; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getBirth() { 28 | return birth; 29 | } 30 | 31 | public void setBirth(String birth) { 32 | this.birth = birth; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/converter/User2UserDtoMapper.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.converter; import com.qianlq.customer.model.entity.UserEntity; import com.qianlq.customer.model.dto.UserDto; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; import java.util.List; @Mapper(componentModel = "spring") public interface User2UserDtoMapper { User2UserDtoMapper INSTANCE = Mappers.getMapper(User2UserDtoMapper.class); @Mappings({ @Mapping(target = "id", source = "user.id"), @Mapping(target = "name", source = "user.name"), @Mapping(target = "birth", source = "user.birth") }) UserDto user2UserDto(UserEntity user); List user2UserDto(List users); } -------------------------------------------------------------------------------- /service-customer/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ██████╗██╗ ██╗███████╗████████╗ ██████╗ ███╗ ███╗███████╗██████╗ 2 | ██╔════╝██║ ██║██╔════╝╚══██╔══╝██╔═══██╗████╗ ████║██╔════╝██╔══██╗ 3 | ██║ ██║ ██║███████╗ ██║ ██║ ██║██╔████╔██║█████╗ ██████╔╝ 4 | ██║ ██║ ██║╚════██║ ██║ ██║ ██║██║╚██╔╝██║██╔══╝ ██╔══██╗ 5 | ╚██████╗╚██████╔╝███████║ ██║ ╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║ 6 | ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ 7 | ░ ░▒ ▒ ░░ ▒░▒░▒░ ▒▒▓ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░░░ ▒▒░ ▒ ░▓ ▒▒ ▓▒█░░ ▒░ 8 | ░ ▒ ░ ▒ ▒░ ░ ▒ ▒ ░ ░ ░ ░▒ ░ ▒░ ░ ▒░ ░ ▒ ░ ▒ ▒▒ ░░ ░░ 9 | ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░ ▒ ░ 10 | ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ 11 | ░ -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/message/Producer.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.message; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.springframework.cloud.stream.annotation.EnableBinding; 6 | import org.springframework.messaging.support.MessageBuilder; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @EnableBinding(Channel.class) 11 | public class Producer { 12 | 13 | private final Logger LOGGER = LogManager.getLogger(Producer.class); 14 | 15 | @Resource 16 | private Channel channel; 17 | 18 | public void produce(String message) { 19 | LOGGER.info("发送消息: {}", message); 20 | channel.producer().send(MessageBuilder.withPayload(message).build()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /service-producer/support/src/main/java/com/qianlq/support/client/TestClient.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.support.client; 2 | 3 | import com.qianlq.support.client.hystrix.HystrixClientFallBack; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @FeignClient(name = "service-producer", fallback = HystrixClientFallBack.class) 10 | public interface TestClient { 11 | 12 | /** 13 | * 测试方法 14 | * 15 | * @param text 测试数据 16 | * @return text 17 | */ 18 | @RequestMapping(value = "/service-producer/v2/test", method = RequestMethod.GET) 19 | String test(@RequestParam(value = "text") String text); 20 | } 21 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/message/Channel.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.message; 2 | 3 | import org.springframework.cloud.stream.annotation.Input; 4 | import org.springframework.cloud.stream.annotation.Output; 5 | import org.springframework.messaging.MessageChannel; 6 | import org.springframework.messaging.SubscribableChannel; 7 | 8 | public interface Channel { 9 | 10 | String CONSUMER = "consumer-test"; 11 | String PRODUCER = "producer-test"; 12 | 13 | /** 14 | * 消息消费者 15 | * 16 | * @return SubscribableChannel 17 | */ 18 | @Input(Channel.CONSUMER) 19 | SubscribableChannel consumer(); 20 | 21 | /** 22 | * 消息生产者 23 | * 24 | * @return MessageChannel 25 | */ 26 | @Output(Channel.PRODUCER) 27 | MessageChannel producer(); 28 | } 29 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/BaseResult.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common; 2 | 3 | import com.qianlq.customer.common.constant.Code; 4 | 5 | public final class BaseResult { 6 | 7 | private int code; 8 | private String message; 9 | private T data; 10 | 11 | 12 | 13 | public BaseResult(T data) { 14 | this(Code.SUCCESS, data); 15 | } 16 | 17 | public BaseResult(Code code) { 18 | this(code, (T) new Object()); 19 | } 20 | 21 | public BaseResult(Code code, T data) { 22 | this.code = code.getCode(); 23 | this.message = code.getMsg(); 24 | this.data = data; 25 | } 26 | 27 | public BaseResult(int code, String message, T data) { 28 | this.code = code; 29 | this.message = message; 30 | this.data = data; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.exception; 2 | 3 | import com.qianlq.customer.common.constant.Code; 4 | 5 | public abstract class BaseException extends RuntimeException { 6 | 7 | private final int code; 8 | 9 | private final String msg; 10 | 11 | BaseException() { 12 | this(Code.FAILED); 13 | } 14 | 15 | BaseException(String msg) { 16 | this(Code.FAILED.getCode(), msg); 17 | } 18 | 19 | BaseException(Code code) { 20 | this(code.getCode(), code.getMsg()); 21 | } 22 | 23 | BaseException(int code, String msg) { 24 | super(msg); 25 | this.code = code; 26 | this.msg = msg; 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | 33 | public String getMsg() { 34 | return msg; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /service-customer/src/test/java/com/qianlq/customer/service/TestServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.service; 2 | 3 | import com.qianlq.customer.common.exception.BusinessException; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | @SpringBootTest 12 | @RunWith(SpringRunner.class) 13 | public class TestServiceTest { 14 | 15 | @Autowired 16 | private TestService testService; 17 | 18 | @Test 19 | public void test() { 20 | Assert.assertEquals(testService.test("hello"), "hello"); 21 | } 22 | 23 | @Test(expected = BusinessException.class) 24 | public void testException() { 25 | testService.testException("test exception"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/exception/GlobalExceptionHandlerAdvice.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.exception; 2 | 3 | import com.qianlq.customer.common.BaseResult; 4 | import com.qianlq.customer.common.constant.Code; 5 | import org.apache.logging.log4j.LogManager; 6 | import org.apache.logging.log4j.Logger; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.RestControllerAdvice; 9 | 10 | /** 11 | * 全局异常捕获 12 | */ 13 | @RestControllerAdvice 14 | public class GlobalExceptionHandlerAdvice { 15 | 16 | private final Logger LOGGER = LogManager.getLogger(GlobalExceptionHandlerAdvice.class); 17 | 18 | @ExceptionHandler(BusinessException.class) 19 | public BaseResult handleBusinessException(BusinessException e) { 20 | LOGGER.error(e); 21 | return new BaseResult<>(Code.FAILED, e.getMsg()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/model/entity/UserEntity.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.model.entity; 2 | 3 | public class UserEntity extends BaseEntity { 4 | 5 | private String id; 6 | 7 | private String name; 8 | 9 | private String birth; 10 | 11 | public UserEntity(String id, String name, String birth) { 12 | this.id = id; 13 | this.name = name; 14 | this.birth = birth; 15 | } 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getBirth() { 34 | return birth; 35 | } 36 | 37 | public void setBirth(String birth) { 38 | this.birth = birth; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/config/HystrixConfig.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.config; 2 | 3 | import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; 4 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class HystrixConfig { 10 | 11 | @Bean 12 | public ServletRegistrationBean getServlet() { 13 | HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); 14 | ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(streamServlet); 15 | registrationBean.setLoadOnStartup(1); 16 | registrationBean.addUrlMappings("/hystrix.stream"); 17 | registrationBean.setName("HystrixMetricsStreamServlet"); 18 | return registrationBean; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /service-producer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | service-producer 6 | 2.3.0-SNAPSHOT 7 | pom 8 | 9 | service-producer 10 | Service producer 11 | 12 | 13 | core 14 | support 15 | 16 | 17 | 18 | com.qianlq 19 | spring-cloud-parent 20 | 1.3.0-SNAPSHOT 21 | 22 | 23 | 24 | ${project.version} 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/common/constant/Code.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.common.constant; 2 | 3 | /** 4 | * [-999,999] 通用模块 5 | * [1000 - 1999] 登录注册,权限校验 6 | * [2000 - 2999] 7 | * [3000 - 3999] 8 | * [4000 - 4999] 9 | * [5000 - 5999] 10 | * [6000 - 6999] 11 | * [7000 - 7999] 12 | * [8000 - 9000] 13 | * [9000 - 9999] 系统通用模块 14 | */ 15 | 16 | public enum Code { 17 | 18 | // 通用模块 19 | FAILED(-1, "失败"), 20 | SUCCESS(0, "成功"), 21 | DEBUG(1, "调试模式"), 22 | PARAM_NULL(-2, "参数不完整"), 23 | 24 | SERVICE_ERROR(8000, "服务异常"), 25 | 26 | // 系统通用模块 27 | BACK_DOORS(9008, "环境异常"), 28 | NET_ERROR(9009, "网络错误"); 29 | 30 | private final int code; 31 | private final String msg; 32 | 33 | Code(int code, String msg) { 34 | this.code = code; 35 | this.msg = msg; 36 | } 37 | 38 | public String getMsg() { 39 | return msg; 40 | } 41 | 42 | public int getCode() { 43 | return code; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /service-producer/core/src/main/java/com/qianlq/core/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.core.controller; 2 | 3 | import com.qianlq.core.service.TestService; 4 | import com.qianlq.support.client.TestClient; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import io.swagger.annotations.ApiParam; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @Api(value = "test-controller", tags = "测试模块") 13 | public class TestController implements TestClient { 14 | 15 | private final TestService testService; 16 | 17 | public TestController(TestService testService) { 18 | this.testService = testService; 19 | } 20 | 21 | @Override 22 | @ApiOperation(value = "测试方法", notes = "返回测试数据", response = String.class) 23 | public String test(@ApiParam(value = "测试数据", required = true) @RequestParam(value = "text") String text) { 24 | return testService.test(text); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.1' 2 | services: 3 | # 注册中心 4 | eureka-server: 5 | image: qianlq/eureka-server 6 | container_name: eureka-server 7 | hostname: eureka-server 8 | restart: always 9 | ports: 10 | - 8761:8761 11 | # 服务网关 12 | api-gateway: 13 | image: qianlq/api-gateway 14 | container_name: api-gateway 15 | restart: always 16 | ports: 17 | - 9090:9090 18 | links: 19 | - eureka-server 20 | # 配置中心 21 | config-server: 22 | image: qianlq/config-server 23 | container_name: config-server 24 | hostname: config-server 25 | restart: always 26 | ports: 27 | - 8504:8504 28 | links: 29 | - eureka-server 30 | 31 | service-producer: 32 | image: qianlq/service-producer-core 33 | container_name: service-producer 34 | restart: always 35 | ports: 36 | - 8100:8100 37 | links: 38 | - eureka-server 39 | 40 | service-customer: 41 | image: qianlq/service-customer 42 | container_name: service-customer 43 | ports: 44 | - 8200:8200 45 | links: 46 | - eureka-server 47 | - config-server -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2020 CoderQian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/service/TestService.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.service; 2 | 3 | import com.qianlq.customer.common.BaseResult; 4 | import com.qianlq.customer.model.dto.UserDto; 5 | 6 | public interface TestService { 7 | 8 | /** 9 | * 测试接口 10 | * 11 | * @param text 测试数据 12 | * @return String 13 | */ 14 | String test(String text); 15 | 16 | /** 17 | * 测试接口 18 | * 19 | * @param text 测试数据 20 | */ 21 | void testException(String text); 22 | 23 | /** 24 | * 测试接口 25 | * 26 | * @param text 测试数据 27 | * @return BaseResult 28 | */ 29 | BaseResult testBaseResult(String text); 30 | 31 | /** 32 | * 测试服务间调用 33 | * 34 | * @param text 测试数据 35 | * @return BaseResult 36 | */ 37 | BaseResult testClient(String text); 38 | 39 | /** 40 | * 测试消息中间件 41 | * 42 | * @param message 消息内容 43 | */ 44 | void producer(String message); 45 | 46 | /** 47 | * 测试MapStruct 48 | * 49 | * @return BaseResult 50 | */ 51 | BaseResult testMapStruct(); 52 | } 53 | -------------------------------------------------------------------------------- /api-gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9090 3 | 4 | spring: 5 | application: 6 | name: api-gateway 7 | profiles: 8 | active: @profiles.active@ 9 | cloud: 10 | loadbalancer: 11 | retry: 12 | enabled: true 13 | 14 | eureka: 15 | client: 16 | # 表示拉取服务注册信息的间隔 17 | registry-fetch-interval-seconds: 5 18 | instance: 19 | # 表示向server端发送心跳频率 20 | lease-renewal-interval-in-seconds: 5 21 | # 表示等待下一次心跳的超时时间,在这个时间内若没收到下一次心跳,则将移除该instance 22 | lease-expiration-duration-in-seconds: 30 23 | prefer-ip-address: true 24 | 25 | zuul: 26 | # 禁止服务自动添加 27 | ignored-services: '*' 28 | routes: 29 | api-a: 30 | path: /customer/** 31 | service-id: service-customer 32 | api-b: 33 | path: /producer/** 34 | service-id: service-producer 35 | # 开启重试功能 36 | retryable: true 37 | # # 在zuul和服务间增加feign只会增加通讯消耗,并不推荐 38 | # api-c: 39 | # path: /feign/** 40 | # # 由网关分发到feign,再经feign负载均衡 41 | # service-id: feign-server 42 | 43 | management: 44 | endpoints: 45 | web: 46 | exposure: 47 | include: "*" 48 | endpoint: 49 | health: 50 | show-details: always -------------------------------------------------------------------------------- /service-customer/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8200 3 | 4 | spring: 5 | application: 6 | name: service-customer 7 | profiles: 8 | active: @profiles.active@ 9 | aop: 10 | proxy-target-class: true 11 | cloud: 12 | # 根据需要移动到profile 13 | config: 14 | # 指定分支 15 | label: master 16 | # 指定环境 17 | profile: @profiles.active@ 18 | name: service-customer,service-customer-mysql,service-customer-redis 19 | bus: 20 | # 开启总线 21 | enabled: true 22 | trace: 23 | # 打开ack跟踪的标志(默认关闭) 24 | enabled: true 25 | stream: 26 | bindings: 27 | producer: 28 | destination: exchange 29 | exchangeType: topic 30 | consumer: 31 | destination: exchange 32 | group: consumer-test 33 | zipkin: 34 | base-url: http://127.0.0.1:9411 35 | rabbitmq: 36 | host: 127.0.0.1 37 | port: 5672 38 | username: guest 39 | password: guest 40 | 41 | logging: 42 | config: classpath:log4j2.xml 43 | 44 | # 启动hystrix 45 | feign: 46 | hystrix: 47 | enabled: true 48 | 49 | management: 50 | endpoints: 51 | web: 52 | exposure: 53 | include: "*" 54 | endpoint: 55 | health: 56 | show-details: always 57 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/ServiceCustomerApplication.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 9 | import org.springframework.cloud.openfeign.EnableFeignClients; 10 | import org.springframework.retry.annotation.EnableRetry; 11 | 12 | @EnableRetry 13 | @EnableHystrix 14 | @EnableDiscoveryClient 15 | @EnableFeignClients(basePackages = {"com.qianlq.support"}) 16 | @SpringBootApplication(scanBasePackages = {"com.qianlq.support", "com.qianlq.customer"}) 17 | public class ServiceCustomerApplication extends SpringBootServletInitializer { 18 | 19 | @Override 20 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 21 | // 使用外部tomcat启动 22 | return builder.sources(ServiceCustomerApplication.class); 23 | } 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(ServiceCustomerApplication.class, args); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/config/FeignBeanFactoryPostProcessor.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.config; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.beans.factory.config.BeanDefinition; 5 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor; 6 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Arrays; 10 | 11 | @Component 12 | public class FeignBeanFactoryPostProcessor implements BeanFactoryPostProcessor { 13 | 14 | /** 15 | * @param beanFactory bean工厂 16 | * @throws BeansException 17 | */ 18 | @Override 19 | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { 20 | if (containsBeanDefinition(beanFactory, "feignContext", "eurekaAutoServiceRegistration")) { 21 | BeanDefinition definition = beanFactory.getBeanDefinition("feignContext"); 22 | definition.setDependsOn("eurekaAutoServiceRegistration"); 23 | } 24 | } 25 | 26 | private boolean containsBeanDefinition(ConfigurableListableBeanFactory beanFactory, String... beans) { 27 | return Arrays.stream(beans).allMatch(beanFactory::containsBeanDefinition); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /service-producer/support/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | service-producer 9 | com.qianlq 10 | 2.3.0-SNAPSHOT 11 | 12 | 13 | service-producer-support 14 | jar 15 | 16 | service-producer-support 17 | Service producer support 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | provided 24 | 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-openfeign 29 | provided 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/interceptor/MonitorInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.interceptor; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.servlet.HandlerInterceptor; 7 | import org.springframework.web.servlet.ModelAndView; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | @Component 13 | public class MonitorInterceptor implements HandlerInterceptor { 14 | 15 | private final Logger LOGGER = LogManager.getLogger(MonitorInterceptor.class); 16 | 17 | @Override 18 | public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, 19 | Object handler) throws Exception { 20 | httpServletRequest.setAttribute("startTime", System.currentTimeMillis()); 21 | return true; 22 | } 23 | 24 | @Override 25 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, 26 | Object handler, ModelAndView modelAndView) throws Exception { 27 | LOGGER.info("耗时: {}ms", (System.currentTimeMillis() - (long) httpServletRequest.getAttribute("startTime"))); 28 | } 29 | 30 | @Override 31 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, 32 | Object handler, Exception e) throws Exception { 33 | LOGGER.info("耗时: {}ms", (System.currentTimeMillis() - (long) httpServletRequest.getAttribute("startTime"))); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /consul-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.qianlq 8 | spring-cloud-parent 9 | 1.3.0-SNAPSHOT 10 | 11 | 12 | consul-server 13 | 1.0.0-SNAPSHOT 14 | jar 15 | 16 | consul-server 17 | Consul Server as a discovery 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-starter-consul-discovery 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-maven-plugin 36 | 37 | 38 | 39 | repackage 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/interceptor/log/ServiceLogAOP.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.interceptor.log; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.aspectj.lang.reflect.MethodSignature; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.lang.reflect.Method; 13 | import java.lang.reflect.Parameter; 14 | 15 | /** 16 | * 日志切面 17 | */ 18 | @Component 19 | @Aspect 20 | public class ServiceLogAOP { 21 | 22 | private final Logger LOGGER = LogManager.getLogger(ServiceLogAOP.class); 23 | 24 | @Pointcut("execution(public * com.qianlq.customer.service.impl.*.*(..))") 25 | public void logTarget() { 26 | } 27 | 28 | @Around("logTarget()") 29 | public Object serviceThreadLocalHandle(ProceedingJoinPoint joinPoint) throws Throwable { 30 | MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); 31 | Method method = methodSignature.getMethod(); 32 | String methodName = method.getName(); 33 | Parameter[] parameters = method.getParameters(); 34 | String targetClassName = joinPoint.getTarget().getClass().getName(); 35 | Object[] args = joinPoint.getArgs(); 36 | LOGGER.info("className: {}, methodName: {}", targetClassName, methodName); 37 | if (args != null && args.length > 0) { 38 | for (int i = 0; i < args.length; i++) { 39 | LOGGER.info("{}: {}: {}", parameters[i].getName(), parameters[i].getType().getName(), args[i]); 40 | } 41 | } 42 | return joinPoint.proceed(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/config/swagger/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.config.swagger; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.ParameterBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.schema.ModelRef; 10 | import springfox.documentation.service.ApiInfo; 11 | import springfox.documentation.service.Parameter; 12 | import springfox.documentation.spi.DocumentationType; 13 | import springfox.documentation.spring.web.plugins.Docket; 14 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * swagger2配置 21 | */ 22 | @Configuration 23 | @EnableSwagger2 24 | public class Swagger2Config { 25 | 26 | @Bean 27 | public Docket createRestApi() { 28 | 29 | ParameterBuilder tokenPar = new ParameterBuilder(); 30 | List pars = new ArrayList(); 31 | tokenPar.name("x-access-token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); 32 | pars.add(tokenPar.build()); 33 | 34 | return new Docket(DocumentationType.SWAGGER_2) 35 | .apiInfo(apiInfo()) 36 | .select() 37 | .apis(RequestHandlerSelectors.basePackage("com.qianlq.core.controller")) 38 | .paths(PathSelectors.any()) 39 | .build() 40 | .globalOperationParameters(pars); 41 | } 42 | 43 | private ApiInfo apiInfo() { 44 | return new ApiInfoBuilder() 45 | .title("service-customer") 46 | .description("Demo project for Spring Boot") 47 | .termsOfServiceUrl("https://localhostL8200") 48 | .version("1.0") 49 | .build(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /gateway-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | spring-cloud-parent 9 | com.qianlq 10 | 1.3.0-SNAPSHOT 11 | 12 | 13 | gateway-server 14 | 1.0.0-SNAPSHOT 15 | jar 16 | 17 | gateway-server 18 | Spring cloud gateway simple demo 19 | 20 | 21 | 22 | org.springframework.cloud 23 | spring-cloud-starter-gateway 24 | 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-netflix-eureka-client 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-actuator 34 | 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-starter-netflix-hystrix 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-maven-plugin 47 | 48 | 49 | 50 | repackage 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /admin-dashboard/src/main/java/com/qianlq/admin/config/SecuritySecureConfig.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.admin.config; 2 | 3 | import de.codecentric.boot.admin.server.config.AdminServerProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 7 | import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; 8 | import org.springframework.security.web.csrf.CookieCsrfTokenRepository; 9 | 10 | @Configuration 11 | public class SecuritySecureConfig extends WebSecurityConfigurerAdapter { 12 | 13 | private final String adminContextPath; 14 | 15 | public SecuritySecureConfig(AdminServerProperties adminServerProperties) { 16 | this.adminContextPath = adminServerProperties.getContextPath(); 17 | } 18 | 19 | @Override 20 | protected void configure(HttpSecurity http) throws Exception { 21 | SavedRequestAwareAuthenticationSuccessHandler successHandler = 22 | new SavedRequestAwareAuthenticationSuccessHandler(); 23 | successHandler.setTargetUrlParameter("redirectTo"); 24 | successHandler.setDefaultTargetUrl(adminContextPath + "/"); 25 | 26 | http.authorizeRequests() 27 | .antMatchers(adminContextPath + "/assets/**").permitAll() 28 | .antMatchers(adminContextPath + "/login").permitAll() 29 | .anyRequest().authenticated() 30 | .and() 31 | .formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and() 32 | .logout().logoutUrl(adminContextPath + "/logout").and() 33 | .httpBasic().and() 34 | .csrf() 35 | .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) 36 | .ignoringAntMatchers( 37 | adminContextPath + "/instances", 38 | adminContextPath + "/actuator/**" 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /gateway-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | # gateway configuration 5 | spring: 6 | application: 7 | name: gateway-server 8 | cloud: 9 | gateway: 10 | discovery: 11 | locator: 12 | # 开启服务注册与服务发现功能,通过serviceId转发到具体的服务实例 13 | enabled: true 14 | lower-case-service-id: true 15 | routes: 16 | - id: service-customer 17 | uri: lb://service-customer 18 | predicates: 19 | - Path=/customer/** 20 | filters: 21 | - name: Retry 22 | args: 23 | retries: 3 24 | status: 503 25 | - name: Hystrix 26 | args: 27 | name: fallbackcmd 28 | fallbackUri: forward:/fallback 29 | # 使用StripPrefix在转发之前将/customer去掉 30 | - StripPrefix=1 31 | - id: service-producer 32 | uri: lb://service-producer 33 | predicates: 34 | - Path=/producer/** 35 | filters: 36 | - StripPrefix=1 37 | - id: config-server 38 | uri: lb://config-server 39 | predicates: 40 | - Path=/config/** 41 | filters: 42 | - StripPrefix=1 43 | # 跨域访问 44 | # globalcors: 45 | # cors-configurations: 46 | # '[/**]': 47 | # allowedOrigins: "https://www.qianlq.com" 48 | # allowedMethods: 49 | # - GET 50 | 51 | # eureka configuration 52 | eureka: 53 | client: 54 | serviceUrl: 55 | defaultZone: http://localhost:8761/eureka/ 56 | registry-fetch-interval-seconds: 5 57 | instance: 58 | lease-renewal-interval-in-seconds: 5 59 | lease-expiration-duration-in-seconds: 30 60 | prefer-ip-address: true 61 | 62 | # hystrix configuration 63 | hystrix: 64 | metrics: 65 | enabled: true 66 | # 超时时间,默认2000ms 67 | polling-interval-ms: 5000 68 | 69 | # security configuration 70 | management: 71 | endpoints: 72 | web: 73 | exposure: 74 | include: "*" 75 | endpoint: 76 | health: 77 | show-details: always 78 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/qianlq/apigateway/config/fallback/CustomerFallback.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.apigateway.config.fallback; 2 | 3 | import org.springframework.cloud.netflix.zuul.filters.route.FallbackProvider; 4 | import org.springframework.http.HttpHeaders; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.http.client.ClientHttpResponse; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.io.ByteArrayInputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.nio.charset.StandardCharsets; 14 | 15 | @Component 16 | public class CustomerFallback implements FallbackProvider { 17 | 18 | private static final String SERVICE_CUSTOMER = "service-customer"; 19 | 20 | @Override 21 | public String getRoute() { 22 | return SERVICE_CUSTOMER; 23 | } 24 | 25 | @Override 26 | public ClientHttpResponse fallbackResponse(String route, Throwable cause) { 27 | return new ClientHttpResponse() { 28 | @Override 29 | public HttpStatus getStatusCode() throws IOException { 30 | return HttpStatus.OK; 31 | } 32 | 33 | @Override 34 | public int getRawStatusCode() throws IOException { 35 | return HttpStatus.OK.value(); 36 | } 37 | 38 | @Override 39 | public String getStatusText() throws IOException { 40 | return HttpStatus.OK.getReasonPhrase(); 41 | } 42 | 43 | @Override 44 | public void close() { 45 | 46 | } 47 | 48 | @Override 49 | public InputStream getBody() throws IOException { 50 | return new ByteArrayInputStream(("The " + route + " is unavailable.").getBytes(StandardCharsets.UTF_8)); 51 | } 52 | 53 | @Override 54 | public HttpHeaders getHeaders() { 55 | HttpHeaders headers = new HttpHeaders(); 56 | headers.setContentType(MediaType.APPLICATION_JSON_UTF8); 57 | return headers; 58 | } 59 | }; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/config/interceptors/WebAppConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.config.interceptors; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import com.qianlq.customer.interceptor.MonitorInterceptor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.http.converter.HttpMessageConverter; 10 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 配置自定义拦截器 17 | */ 18 | @Configuration 19 | public class WebAppConfigurer extends WebMvcConfigurationSupport { 20 | 21 | @Autowired 22 | private MonitorInterceptor monitorInterceptor; 23 | 24 | @Override 25 | public void addInterceptors(InterceptorRegistry registry) { 26 | // registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**"); 27 | registry.addInterceptor(monitorInterceptor); 28 | super.addInterceptors(registry); 29 | } 30 | 31 | @Override 32 | public void configureMessageConverters(List> converters) { 33 | super.configureMessageConverters(converters); 34 | 35 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 36 | 37 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 38 | 39 | // PrettyFormat:结果是否格式化,默认为false 40 | // WriteMapNullValue:是否输出值为null的字段,默认为false 41 | // DisableCircularReferenceDetect:消除对同一对象循环引用的问题,默认为false 42 | fastJsonConfig.setSerializerFeatures( 43 | SerializerFeature.PrettyFormat, 44 | SerializerFeature.WriteMapNullValue, 45 | SerializerFeature.DisableCircularReferenceDetect 46 | ); 47 | fastConverter.setFastJsonConfig(fastJsonConfig); 48 | 49 | converters.add(fastConverter); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /service-producer/core/src/main/java/com/qianlq/core/config/swagger/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.core.config.swagger; 2 | 3 | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.Import; 7 | import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; 8 | import springfox.documentation.builders.ApiInfoBuilder; 9 | import springfox.documentation.builders.ParameterBuilder; 10 | import springfox.documentation.builders.PathSelectors; 11 | import springfox.documentation.builders.RequestHandlerSelectors; 12 | import springfox.documentation.schema.ModelRef; 13 | import springfox.documentation.service.ApiInfo; 14 | import springfox.documentation.service.Parameter; 15 | import springfox.documentation.spi.DocumentationType; 16 | import springfox.documentation.spring.web.plugins.Docket; 17 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * swagger2配置 24 | */ 25 | @Configuration 26 | @EnableKnife4j 27 | @EnableSwagger2 28 | @Import(BeanValidatorPluginsConfiguration.class) 29 | public class Swagger2Config { 30 | 31 | @Bean 32 | public Docket createRestApi() { 33 | 34 | ParameterBuilder tokenPar = new ParameterBuilder(); 35 | List pars = new ArrayList(); 36 | tokenPar.name("x-access-token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); 37 | pars.add(tokenPar.build()); 38 | 39 | return new Docket(DocumentationType.SWAGGER_2) 40 | .apiInfo(apiInfo()) 41 | .select() 42 | .apis(RequestHandlerSelectors.basePackage("com.qianlq.core.controller")) 43 | .paths(PathSelectors.any()) 44 | .build() 45 | .globalOperationParameters(pars); 46 | } 47 | 48 | private ApiInfo apiInfo() { 49 | return new ApiInfoBuilder() 50 | .title("service-producer") 51 | .description("Demo project for Spring Boot") 52 | .termsOfServiceUrl("http://localhost:8100") 53 | .version("1.0") 54 | .build(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/service/impl/TestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.service.impl; import com.qianlq.customer.common.BaseResult; import com.qianlq.customer.common.BaseResultFactory; import com.qianlq.customer.common.constant.Code; import com.qianlq.customer.common.exception.BusinessException; import com.qianlq.customer.common.message.Channel; import com.qianlq.customer.converter.User2UserDtoMapper; import com.qianlq.customer.model.dto.UserDto; import com.qianlq.customer.model.entity.UserEntity; import com.qianlq.customer.service.TestService; import com.qianlq.support.client.TestClient; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.messaging.support.MessageBuilder; import org.springframework.stereotype.Service; @Service @EnableBinding(Channel.class) public class TestServiceImpl implements TestService { private final Logger LOGGER = LogManager.getLogger(TestServiceImpl.class); private final TestClient testClient; private final Channel channel; public TestServiceImpl(TestClient testClient, Channel channel) { this.testClient = testClient; this.channel = channel; } @Override public String test(String text) { return text; } @Override public void testException(String text) throws BusinessException { throw new BusinessException(text); } @Override public BaseResult testBaseResult(String text) { LOGGER.info("日志测试:{}", text); return new BaseResult<>(Code.SUCCESS, text); } @Override public BaseResult testClient(String text) { return new BaseResult<>(Code.SUCCESS, testClient.test(text)); } @Override public void producer(String message) { LOGGER.info("发送消息: {}", message); channel.producer().send(MessageBuilder.withPayload(message).build()); } @StreamListener(Channel.CONSUMER) public void consume(String message) { LOGGER.info("接收消息: {}", message); } @Override public BaseResult testMapStruct() { UserEntity user = new UserEntity("21851123", "CoderQian", "1995-08-24"); UserDto dto = User2UserDtoMapper.INSTANCE.user2UserDto(user); return BaseResultFactory.createSuccessResult(dto); } } -------------------------------------------------------------------------------- /admin-dashboard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.qianlq 9 | spring-cloud-parent 10 | 1.3.0-SNAPSHOT 11 | 12 | 13 | admin-dashboard 14 | 1.0.0-SNAPSHOT 15 | jar 16 | 17 | admin-dashboard 18 | Spring boot admin dashboard server 19 | 20 | 21 | 2.1.6 22 | 23 | 24 | 25 | 26 | de.codecentric 27 | spring-boot-admin-starter-server 28 | ${spring-boot-admin-server.version} 29 | 30 | 31 | 32 | de.codecentric 33 | spring-boot-admin-server-ui 34 | ${spring-boot-admin-server.version} 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-security 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-starter-netflix-eureka-client 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-maven-plugin 58 | 59 | 60 | 61 | repackage 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /eureka-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.qianlq 8 | spring-cloud-parent 9 | 1.3.0-SNAPSHOT 10 | 11 | 12 | eureka-server 13 | 1.0.0-SNAPSHOT 14 | jar 15 | 16 | eureka-server 17 | Eureka server as a discovery 18 | 19 | 20 | 21 | native 22 | 23 | native 24 | 25 | 26 | true 27 | 28 | 29 | 30 | docker 31 | 32 | docker 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-starter-netflix-eureka-server 42 | 43 | 44 | 45 | 46 | 47 | 48 | true 49 | ${basedir}/src/main/resources 50 | 51 | application.yml 52 | application-${profiles.active}.yml 53 | banner.txt 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | repackage 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /config-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.qianlq 8 | spring-cloud-parent 9 | 1.3.0-SNAPSHOT 10 | 11 | 12 | config-server 13 | 1.0.0-SNAPSHOT 14 | jar 15 | 16 | config-server 17 | Configuration center 18 | 19 | 20 | 21 | native 22 | 23 | native 24 | 25 | 26 | true 27 | 28 | 29 | 30 | docker 31 | 32 | docker 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-netflix-eureka-client 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-config-server 46 | 47 | 48 | 49 | 50 | 51 | 52 | true 53 | ${basedir}/src/main/resources 54 | 55 | application.yml 56 | application-${profiles.active}.yml 57 | banner.txt 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | repackage 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /turbine-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | turbine-server 8 | 1.0.0-SNAPSHOT 9 | jar 10 | 11 | turbine-server 12 | Turbine server 13 | 14 | 15 | spring-cloud-parent 16 | com.qianlq 17 | 1.3.0-SNAPSHOT 18 | 19 | 20 | 21 | 22 | native 23 | 24 | native 25 | 26 | 27 | true 28 | 29 | 30 | 31 | docker 32 | 33 | docker 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-starter-netflix-turbine 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-actuator 47 | 48 | 49 | 50 | 51 | 52 | 53 | true 54 | ${basedir}/src/main/resources 55 | 56 | application.yml 57 | application-${profiles.active}.yml 58 | banner.txt 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-maven-plugin 67 | 68 | 69 | 70 | repackage 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /api-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.qianlq 8 | spring-cloud-parent 9 | 1.3.0-SNAPSHOT 10 | 11 | 12 | api-gateway 13 | jar 14 | 1.3.0-SNAPSHOT 15 | 16 | api-gateway 17 | Zuul for api gateway 18 | 19 | 20 | 21 | native 22 | 23 | native 24 | 25 | 26 | true 27 | 28 | 29 | 30 | docker 31 | 32 | docker 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-netflix-zuul 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-starter-netflix-eureka-client 46 | 47 | 48 | 49 | org.springframework.retry 50 | spring-retry 51 | 52 | 53 | 54 | 55 | 56 | 57 | true 58 | ${basedir}/src/main/resources 59 | 60 | application.yml 61 | application-${profiles.active}.yml 62 | banner.txt 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-maven-plugin 71 | 72 | 73 | 74 | repackage 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /hystrix-dashboard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | spring-cloud-parent 9 | com.qianlq 10 | 1.3.0-SNAPSHOT 11 | 12 | 13 | hystrix-dashboard 14 | 1.0.0-SNAPSHOT 15 | jar 16 | 17 | hystrix-dashboard 18 | Hystrix Dashboard 19 | 20 | 21 | 22 | native 23 | 24 | native 25 | 26 | 27 | true 28 | 29 | 30 | 31 | docker 32 | 33 | docker 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-starter-netflix-eureka-client 42 | 43 | 44 | 45 | org.springframework.cloud 46 | spring-cloud-starter-netflix-hystrix 47 | 48 | 49 | 50 | org.springframework.cloud 51 | spring-cloud-starter-netflix-hystrix-dashboard 52 | 53 | 54 | 55 | 56 | 57 | 58 | true 59 | ${basedir}/src/main/resources 60 | 61 | application.yml 62 | application-${profiles.active}.yml 63 | banner.txt 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | 75 | repackage 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /zipkin-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | zipkin-server 7 | 1.0.0-SNAPSHOT 8 | jar 9 | 10 | zipkin-server 11 | Zipkin Server 12 | 13 | 14 | com.qianlq 15 | spring-cloud-parent 16 | 1.3.0-SNAPSHOT 17 | 18 | 19 | 20 | 2.11.8 21 | 22 | 23 | 24 | 25 | native 26 | 27 | native 28 | 29 | 30 | true 31 | 32 | 33 | 34 | docker 35 | 36 | docker 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-netflix-eureka-client 45 | 46 | 47 | 48 | io.zipkin.java 49 | zipkin-server 50 | ${zipkin-server.version} 51 | 52 | 53 | 54 | io.zipkin.java 55 | zipkin-autoconfigure-ui 56 | ${zipkin-server.version} 57 | 58 | 59 | 60 | 61 | 62 | 63 | true 64 | ${basedir}/src/main/resources 65 | 66 | application.yml 67 | application-${profiles.active}.yml 68 | banner.txt 69 | 70 | 71 | 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-maven-plugin 76 | 77 | 78 | 79 | repackage 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /service-customer/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} [Thread: %t] [ %-5p] %c{1}:%L - %m%n 8 | logs 9 | service-customer 10 | 11 | 12 | 13 | 14 | 15 | ${pattern} 16 | 17 | 18 | 19 | 20 | 21 | 22 | ${pattern} 23 | 24 | 25 | 26 | 28 | 29 | 30 | ${pattern} 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | ${pattern} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | ${pattern} 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /service-customer/src/main/java/com/qianlq/customer/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.qianlq.customer.controller; 2 | 3 | import com.qianlq.customer.common.BaseResult; 4 | import com.qianlq.customer.model.dto.UserDto; 5 | import com.qianlq.customer.service.TestService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import io.swagger.annotations.ApiParam; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.cloud.context.config.annotation.RefreshScope; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RequestParam; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | @RefreshScope 17 | @RestController 18 | @RequestMapping(value = "/v1/test") 19 | @Api(value = "test-controller", tags = "测试模块") 20 | public class TestController { 21 | 22 | @Value("${profile}") 23 | private String profile; 24 | 25 | @Value("${mysql}") 26 | private String mysql; 27 | 28 | @Value("${redis}") 29 | private String redis; 30 | 31 | private final TestService testService; 32 | 33 | public TestController(TestService testService) { 34 | this.testService = testService; 35 | } 36 | 37 | @ApiOperation(value = "返回用户输入的结果", notes = "返回用户输入的结果", response = String.class) 38 | @RequestMapping(value = "/result", method = RequestMethod.GET) 39 | public String test(@ApiParam(value = "测试内容", required = true) @RequestParam(value = "text") String text) { 40 | return testService.test(text); 41 | } 42 | 43 | @ApiOperation(value = "测试全局异常捕获", notes = "测试全局异常捕获") 44 | @RequestMapping(value = "/exception", method = RequestMethod.GET) 45 | public void testException(@ApiParam(value = "测试内容", required = true) @RequestParam(value = "text") String text) { 46 | testService.testException(text); 47 | } 48 | 49 | @ApiOperation(value = "测试baseResult", notes = "返回统一的baseResult,推荐使用这种方式,所有的返回结果统一用baseResult组装", response = String.class) 50 | @RequestMapping(value = "/baseResult", method = RequestMethod.GET) 51 | public BaseResult testBaseResult(@ApiParam(value = "测试内容", required = true) @RequestParam(value = "text") String text) { 52 | return testService.testBaseResult(text); 53 | } 54 | 55 | @ApiOperation(value = "测试服务间调用", notes = "测试服务间调用", response = String.class) 56 | @RequestMapping(value = "/client", method = RequestMethod.GET) 57 | public BaseResult testClient(@RequestParam(value = "text") String text) { 58 | return testService.testClient(text); 59 | } 60 | 61 | @ApiOperation(value = "读取配置文件", notes = "读取配置文件", response = String.class) 62 | @RequestMapping(value = "/config", method = RequestMethod.GET) 63 | public String testConfig() { 64 | return "mysql:" + mysql + ", redis:" + redis; 65 | } 66 | 67 | @ApiOperation(value = "测试消息总线", notes = "测试消息总线", response = String.class) 68 | @RequestMapping(value = "/bus", method = RequestMethod.GET) 69 | public String testBus() { 70 | return profile; 71 | } 72 | 73 | @ApiOperation(value = "测试消息驱动", notes = "测试消息驱动") 74 | @RequestMapping(value = "/stream", method = RequestMethod.POST) 75 | public void testStream(@ApiParam(value = "message") @RequestParam(value = "message") String message) { 76 | testService.producer(message); 77 | } 78 | 79 | @ApiOperation(value = "测试MapStruct", notes = "测试MapStruct", response = UserDto.class) 80 | @RequestMapping(value = "/struct", method = RequestMethod.GET) 81 | public BaseResult testMapStruct() { 82 | return testService.testMapStruct(); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /service-producer/core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | service-producer 9 | com.qianlq 10 | 2.3.0-SNAPSHOT 11 | 12 | 13 | service-producer-core 14 | jar 15 | 16 | service-producer-core 17 | Service producer core 18 | 19 | 20 | [24.1.1,) 21 | 2.0.2 22 | 23 | 24 | 25 | 26 | native 27 | 28 | native 29 | 30 | 31 | true 32 | 33 | 34 | 35 | docker 36 | 37 | docker 38 | 39 | 40 | 41 | 42 | 43 | 44 | com.qianlq 45 | service-producer-support 46 | ${service-producer.version} 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-web 52 | 53 | 54 | 55 | org.springframework.cloud 56 | spring-cloud-starter-netflix-eureka-client 57 | 58 | 59 | com.google.guava 60 | guava 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-actuator 68 | 69 | 70 | 71 | com.github.xiaoymin 72 | knife4j-spring-boot-starter 73 | ${knife4j.version} 74 | 75 | 76 | 77 | com.google.guava 78 | guava 79 | ${guava.version} 80 | compile 81 | 82 | 83 | 84 | 85 | 86 | 87 | true 88 | ${basedir}/src/main/resources 89 | 90 | application.yml 91 | application-${profiles.active}.yml 92 | banner.txt 93 | 94 | 95 | 96 | 97 | 98 | 99 | org.springframework.boot 100 | spring-boot-maven-plugin 101 | 102 | 103 | 104 | repackage 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /README-zh.md: -------------------------------------------------------------------------------- 1 | # Spring-Cloud-Learning 2 | 3 | [![Build Status](https://travis-ci.org/coderqianlq/spring-cloud-learning.svg?branch=master)](https://travis-ci.org/coderqianlq/spring-cloud-learning) 4 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 5 | [![Coverage Status](https://coveralls.io/repos/github/coderqianlq/spring-cloud-learning/badge.svg?branch=master)](https://coveralls.io/github/coderqianlq/spring-cloud-learning?branch=master) 6 | 7 | README: [English](README.md) | [中文](README-zh.md) 8 | 9 | spring-cloud-learning适合刚接触微服务架构的初学者用来初步了解和学习微服务,主要集成了注册中心,服务网关,配置中心,熔断机制和应用监控。 10 | 11 | ## 目录 12 | 13 | * [微服务组件](#微服务组件) 14 | * [Getting Started](#getting-started) 15 | * [本地启动(推荐)](#本地启动(推荐)) 16 | * [Docker启动](#Docker启动) 17 | * [截图预览](#截图预览) 18 | * [模块预览](#模块预览) 19 | * [依赖版本](#依赖版本) 20 | * [Todo List](#todo-list) 21 | * [Collaborators](#collaborators) 22 | * [License](#license) 23 | 24 | ## 微服务组件 25 | 26 | - [x] Eureka 27 | - [x] Consul 28 | - [ ] Ribbon 29 | - [x] Feign 30 | - [x] Hystrix 31 | - [x] Turbine 32 | - [x] Zuul 33 | - [x] Spring Cloud Config 34 | - [x] Spring Cloud Stream 35 | - [x] Spring Cloud Bus 36 | - [ ] Spring Cloud Sleuth 37 | - [ ] Spring Cloud Security 38 | - [ ] Spring Cloud Task 39 | - [x] Spring Cloud Gateway 40 | 41 | 补充中... 42 | 43 | ## Getting Started 44 | 45 | 主要介绍两种启动方式,现在还是推荐本地启动,Docker还在学习中,而且服务比较多,现在只配置了几个主要的服务。 46 | 47 | 首先克隆代码到本地。 48 | 49 | ``` 50 | $ git clone https://github.com/coderqianlq/spring-cloud-learning.git 51 | ``` 52 | 53 | ### 本地启动(推荐) 54 | 55 | 使用IDE以maven方式打开项目,并使用IDE或者命令行启动项目。 56 | 57 | ``` 58 | $ mvn spring-boot:run 59 | ``` 60 | 61 | 或者打包项目后使用jar命令启动。 62 | 63 | ``` 64 | $ java -jar xxx.jar 65 | ``` 66 | 67 | ### Docker启动 68 | 69 | 首先,确认已经安装docker并启动它。 70 | 71 | ``` 72 | $ docker --version 73 | Docker version 18.06.1-ce, build e68fc7a 74 | ``` 75 | 76 | 然后,进入每个子模块执行docker构建命令。 77 | 78 | ``` 79 | $ cd eureka-server 80 | 81 | $ mvn clean package -Pdocker docker:build 82 | ``` 83 | 84 | 接着,返回父模块执行docker-compose命令。 85 | 86 | ``` 87 | $ docker-compose up -d 88 | ``` 89 | 90 | 最后,你可以打开注册中心(默认url: [http://localhost:8761](http://localhost:8761))查看服务是否注册成功。 91 | 92 | ## 截图预览 93 | 94 | ![Spring boot admin wallboard](screenshots/Spring%20boot%20admin%20wallboard.png) 95 | 96 | ![Spring Boot admin detail](screenshots/Spring%20boot%20admin%20detail.png) 97 | 98 | ![Service customer hystrix stream](screenshots/Service%20customer%20hystrix%20stream.png) 99 | 100 | ![Hystrix monitor](screenshots/Hystrix%20monitor.png) 101 | 102 | ## 模块预览 103 | 104 | | - | port | remarks | 105 | | :------------- | :----------: | :-------------: | 106 | | admin-dashboard | 8040 | Spring boot admin dashboard 监控服务 | 107 | | api-gateway | 9090 | 服务网关(Zuul) | 108 | | config-server | 8504 | 如果修改了该模块端口,你需要同时修改service-customer模块的bootstrap.yml配置中心的端口 | 109 | | consul-server | 8502 | 服务发现(Consul) | 110 | | eureka-server | 8761 | 服务发现(Eureka) | 111 | | gateway-server | 8080 | 服务网关(Gateway) | 112 | | hystrix-dashboard | 8050 | | 113 | | service-customer | 8200 | 集成了多个组件的使用,包括Feign, Spring Cloud Config, Spring Cloud Stream, Spring Cloud Bus, 后面有时间拆出去 | 114 | | service-producer | 8100 | | 115 | | turbine-server | 8060 | | 116 | | zipkin-server | 9411 | 同config-server的备注 | 117 | 118 | ## 依赖版本 119 | 120 | | Spring Boot | Spring Cloud | Spring Boot Admin | Swagger2 | 121 | | :---------: | :----------: | :---------------: | :------: | 122 | | 2.1.5 | Greenwich | 2.1.6 | 2.7.0 | 123 | 124 | ## Todo List 125 | 126 | - [ ] 拆分service-customer服务(这个服务太笨重了,一开始想着自个练习用,不利于初学Spring Cloud的程序员👨‍💻们‍使用)。 127 | - [x] 添加监控hystrix和集群监控turbine的详细用法。 128 | - [x] 升级Spring Boot 2.0, 同时升级Spring Cloud Greenwich。 129 | - [x] 添加Spring Boot admin dashboard。 130 | - [x] 使用Spring Cloud Gateway替代Zuul做服务网关(应该还会保留Zuul)。 131 | 132 | ## Collaborators 133 | 134 | 135 | 136 | 137 | 144 | 151 | 158 | 159 |
138 | 139 | 140 |
141 | Marveliu 142 |
143 |
145 | 146 | 147 |
148 | Joby1230 149 |
150 |
152 | 153 | 154 |
155 | wxaaaa 156 |
157 |
160 | 161 | ## License 162 | [MIT](LICENSE) © CoderQian -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring-Cloud-Learning 2 | 3 | [![Build Status](https://travis-ci.org/coderqianlq/spring-cloud-learning.svg?branch=master)](https://travis-ci.org/coderqianlq/spring-cloud-learning) 4 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 5 | [![Coverage Status](https://coveralls.io/repos/github/coderqianlq/spring-cloud-learning/badge.svg?branch=master)](https://coveralls.io/github/coderqianlq/spring-cloud-learning?branch=master) 6 | 7 | README: [English](README.md) | [中文](README-zh.md) 8 | 9 | spring-cloud-learning can be used as a project to learn microservices, and it's mainly contain service discovery, service gateway, configuration management, circuit breakers, application monitor. 10 | 11 | ## Table of Contents 12 | 13 | * [Components](#components) 14 | * [Getting Started](#getting-started) 15 | * [Use directly (recommend)](#use-directly-recommend) 16 | * [Use docker](#use-docker) 17 | * [Preview](#preview) 18 | * [Modules](#modules) 19 | * [Dependency Chart](#dependency-chart) 20 | * [Todo List](#todo-list) 21 | * [Collaborators](#collaborators) 22 | * [License](#license) 23 | 24 | ## Components 25 | 26 | - [x] Eureka 27 | - [x] Consul 28 | - [ ] Ribbon 29 | - [x] Feign 30 | - [x] Hystrix 31 | - [x] Turbine 32 | - [x] Zuul 33 | - [x] Spring Cloud Config 34 | - [x] Spring Cloud Stream 35 | - [x] Spring Cloud Bus 36 | - [ ] Spring Cloud Sleuth 37 | - [ ] Spring Cloud Security 38 | - [ ] Spring Cloud Task 39 | - [x] Spring Cloud Gateway 40 | 41 | To be supplemented... 42 | 43 | ## Getting Started 44 | 45 | Two methods will mainly introduced, but no matter what you need to clone the code. 46 | 47 | ``` 48 | $ git clone https://github.com/coderqianlq/spring-cloud-learning.git 49 | ``` 50 | 51 | ### Use directly (recommend) 52 | 53 | You can use ide to import the project with maven, and use ide or use command line to start project. 54 | 55 | ``` 56 | $ mvn spring-boot:run 57 | ``` 58 | 59 | You can also package the code and run it. 60 | 61 | ``` 62 | $ java -jar xxx.jar 63 | ``` 64 | 65 | ### Use docker 66 | 67 | First, you have to make sure you have installed docker and start docker server. 68 | 69 | ``` 70 | $ docker --version 71 | Docker version 18.06.1-ce, build e68fc7a 72 | ``` 73 | 74 | Then, you need to enter each submodule and execute the docker building command. 75 | 76 | ``` 77 | $ cd eureka-server 78 | 79 | $ mvn clean package -Pdocker docker:build 80 | ``` 81 | 82 | Next, return to the parent module and execute docker-compose command. 83 | 84 | ``` 85 | $ docker-compose up -d 86 | ``` 87 | 88 | Finally, you can open the registration center(default url: http://localhost:8761) to see if the service is registered successfully. 89 | 90 | ## Preview 91 | 92 | ![Spring boot admin wallboard](screenshots/Spring%20boot%20admin%20wallboard.png) 93 | 94 | ![Spring Boot admin detail](screenshots/Spring%20boot%20admin%20detail.png) 95 | 96 | ![Service customer hystrix stream](screenshots/Service%20customer%20hystrix%20stream.png) 97 | 98 | ![Hystrix monitor](screenshots/Hystrix%20monitor.png) 99 | 100 | ## Modules 101 | 102 | | - | port | remarks | 103 | | :------------- | :----------: | :-------------: | 104 | | admin-dashboard | 8040 | Spring boot Admin Dashboard for monitor spring cloud services | 105 | | api-gateway | 9090 | Service gateway(Zuul) | 106 | | config-server | 8504 | if you change the port, you need also modify bootstrap.yml of service-customer. | 107 | | consul-server | 8502 | Service discovery(Consul) | 108 | | eureka-server | 8761 | Service discovery(Eureka) | 109 | | gateway-server | 8080 | Service gateway(Gateway) | 110 | | hystrix-dashboard | 8050 | | 111 | | service-customer | 8200 | Integrated multiple components, including Feign, Spring Cloud Config, Spring Cloud Stream, Spring Cloud Bus | 112 | | service-producer | 8100 | | 113 | | turbine-server | 8060 | | 114 | | zipkin-server | 9411 | if you change the port, you need also modify bootstrap.yml of service-customer. | 115 | 116 | ## Dependency Chart 117 | 118 | | Spring Boot | Spring Cloud | Spring Boot Admin | Swagger2 | 119 | | :---------: | :----------: | :---------------: | :------: | 120 | | 2.1.5 | Greenwich | 2.1.6 | 2.7.0 | 121 | 122 | ## Todo List 123 | 124 | - [ ] Split the module of service-customer. 125 | - [x] Add the detailed usage of hystrix with turbine. 126 | - [x] Update Spring Boot to 2.x and both Spring Cloud to Greenwich. 127 | - [x] Add Spring Boot admin dashboard. 128 | - [x] Use Spring Cloud Gateway replaces zuul as service gateway. 129 | 130 | ## Collaborators 131 | 132 | 133 | 134 | 135 | 142 | 149 | 156 | 157 |
136 | 137 | 138 |
139 | Marveliu 140 |
141 |
143 | 144 | 145 |
146 | Joby1230 147 |
148 |
150 | 151 | 152 |
153 | wxaaaa 154 |
155 |
158 | 159 | ## License 160 | [MIT](LICENSE) © CoderQian -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.qianlq 8 | spring-cloud-parent 9 | 1.3.0-SNAPSHOT 10 | pom 11 | 12 | 13 | eureka-server 14 | service-producer 15 | service-customer 16 | api-gateway 17 | config-server 18 | zipkin-server 19 | consul-server 20 | hystrix-dashboard 21 | turbine-server 22 | admin-dashboard 23 | gateway-server 24 | 25 | 26 | 27 | UTF-8 28 | UTF-8 29 | 1.8 30 | 4.3.0 31 | 0.8.5 32 | 2.1.5.RELEASE 33 | Greenwich.SR2 34 | qianlq 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-dependencies 45 | ${spring-boot.version} 46 | pom 47 | import 48 | 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-dependencies 53 | ${spring-cloud.version} 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-maven-plugin 66 | ${spring-boot.version} 67 | 68 | 69 | 70 | 71 | 72 | 73 | org.apache.maven.plugins 74 | maven-compiler-plugin 75 | 3.5.1 76 | 77 | 1.8 78 | 1.8 79 | 80 | 81 | 82 | com.spotify 83 | docker-maven-plugin 84 | 0.4.13 85 | 86 | ${docker.image.prefix}/${project.artifactId} 87 | ${project.version} 88 | ${project.basedir}/src/main/docker 89 | 90 | 91 | / 92 | ${project.build.directory} 93 | ${project.build.finalName}.jar 94 | 95 | 96 | 97 | 98 | 99 | org.jacoco 100 | jacoco-maven-plugin 101 | ${jacoco.version} 102 | 103 | false 104 | ${project.build.directory}/coverage-reports/jacoco.exec 105 | ${project.build.directory}/coverage-reports/jacoco.exec 106 | 107 | 108 | 109 | default-prepare-agent 110 | 111 | prepare-agent 112 | 113 | 114 | 115 | default-report 116 | test 117 | 118 | report 119 | 120 | 121 | ${project.build.directory}/coverage-reports/jacoco.exec 122 | ${project.build.directory}/coverage-reports 123 | 124 | 125 | 126 | 127 | 128 | org.eluder.coveralls 129 | coveralls-maven-plugin 130 | ${coveralls.version} 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /service-customer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.qianlq 8 | spring-cloud-parent 9 | 1.3.0-SNAPSHOT 10 | 11 | 12 | service-customer 13 | 2.1.0-SNAPSHOT 14 | jar 15 | 16 | service-customer 17 | Demo project for service customer 18 | 19 | 20 | 2.3.0-SNAPSHOT 21 | 2.7.0 22 | 1.2.83 23 | 1.2.0.Final 24 | 25 | 26 | 27 | 28 | native 29 | 30 | native 31 | 32 | 33 | true 34 | 35 | 36 | 37 | docker 38 | 39 | docker 40 | 41 | 42 | 43 | 44 | 45 | 46 | com.qianlq 47 | service-producer-support 48 | ${producer.vsersion} 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-logging 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-web 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-starter-test 70 | test 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-starter-log4j2 77 | 78 | 79 | 80 | 81 | org.springframework.boot 82 | spring-boot-starter-aop 83 | 84 | 85 | 86 | 87 | org.springframework.cloud 88 | spring-cloud-starter-netflix-eureka-client 89 | 90 | 91 | 92 | 93 | org.springframework.cloud 94 | spring-cloud-starter-openfeign 95 | 96 | 97 | 98 | 99 | org.springframework.cloud 100 | spring-cloud-starter-config 101 | 102 | 103 | 104 | 105 | org.springframework.cloud 106 | spring-cloud-starter-bus-amqp 107 | 108 | 109 | 110 | 111 | org.springframework.cloud 112 | spring-cloud-starter-zipkin 113 | 114 | 115 | 116 | 117 | org.springframework.boot 118 | spring-boot-starter-actuator 119 | 120 | 121 | 122 | 123 | org.springframework.cloud 124 | spring-cloud-starter-netflix-hystrix 125 | 126 | 127 | 128 | org.springframework.retry 129 | spring-retry 130 | 131 | 132 | 133 | 134 | io.springfox 135 | springfox-swagger2 136 | ${swagger2.version} 137 | 138 | 139 | org.mapstruct 140 | mapstruct 141 | 142 | 143 | 144 | 145 | 146 | io.springfox 147 | springfox-swagger-ui 148 | ${swagger2.version} 149 | 150 | 151 | 152 | com.alibaba 153 | fastjson 154 | ${fastjson.version} 155 | 156 | 157 | 158 | org.mapstruct 159 | mapstruct 160 | ${mapstruct.version} 161 | 162 | 163 | 164 | org.mapstruct 165 | mapstruct-processor 166 | ${mapstruct.version} 167 | 168 | 169 | 170 | 171 | 172 | 173 | true 174 | ${basedir}/src/main/resources 175 | 176 | bootstrap.yml 177 | bootstrap-${profiles.active}.yml 178 | log4j2.xml 179 | banner.txt 180 | 181 | 182 | 183 | 184 | 185 | org.springframework.boot 186 | spring-boot-maven-plugin 187 | 188 | 189 | 190 | repackage 191 | 192 | 193 | 194 | 195 | 196 | org.apache.maven.plugins 197 | maven-compiler-plugin 198 | 199 | 200 | 201 | org.mapstruct 202 | mapstruct-processor 203 | ${mapstruct.version} 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | --------------------------------------------------------------------------------