├── docker-host ├── microservice-provider-user │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── schema.sql │ │ │ ├── data.sql │ │ │ ├── application.yml │ │ │ ├── application-ha.yml.bak │ │ │ └── application-autherntication.yml.bak │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── ProviderUserApplication.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ └── entity │ │ │ └── User.java │ └── pom.xml ├── microservice-hystrix-dashboard │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── HystrixDashboardApplication.java │ └── pom.xml ├── microservice-discovery-eureka │ ├── src │ │ └── main │ │ │ ├── docker │ │ │ └── Dockerfile │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── EurekaApplication.java │ ├── pom.xml.bak2-指定Dockerfile │ ├── pom.xml │ ├── pom.xml-bak1-快速入门,最简单的示例 │ ├── pom.xml.bak4-推送镜像到Docker Hub │ ├── pom.xml.bak5-使用imageTags指定标签 │ └── pom.xml.bak3-绑定某个phase运行 ├── microservice-gateway-zuul │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── ZuulApplication.java │ └── pom.xml ├── microservice-consumer-movie-ribbon-hystrix │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ ├── ConsumerMovieApplication.java │ │ │ └── user │ │ │ ├── entity │ │ │ └── User.java │ │ │ └── controller │ │ │ └── MovieController.java │ └── pom.xml ├── microservice-hystrix-turbine │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── TurbineApplication.java │ └── pom.xml ├── docker-compose.yml └── pom.xml ├── docker-1-simple ├── microservice-provider-user │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── schema.sql │ │ │ ├── data.sql │ │ │ ├── application.yml │ │ │ ├── application-ha.yml.bak │ │ │ └── application-autherntication.yml.bak │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── ProviderUserApplication.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ └── entity │ │ │ └── User.java │ └── pom.xml ├── microservice-hystrix-dashboard │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── HystrixDashboardApplication.java │ └── pom.xml ├── microservice-discovery-eureka │ ├── src │ │ └── main │ │ │ ├── docker │ │ │ └── Dockerfile │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── EurekaApplication.java │ ├── pom.xml.bak2-指定Dockerfile │ ├── pom.xml │ ├── pom.xml-bak1-快速入门,最简单的示例 │ ├── pom.xml.bak4-推送镜像到Docker Hub │ ├── pom.xml.bak5-使用imageTags指定标签 │ └── pom.xml.bak3-绑定某个phase运行 ├── microservice-gateway-zuul │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── ZuulApplication.java │ └── pom.xml ├── microservice-consumer-movie-ribbon-hystrix │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ ├── ConsumerMovieApplication.java │ │ │ └── user │ │ │ ├── entity │ │ │ └── User.java │ │ │ └── controller │ │ │ └── MovieController.java │ └── pom.xml ├── microservice-hystrix-turbine │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── TurbineApplication.java │ └── pom.xml ├── docker-compose-easy.yml ├── docker-compose.yml └── pom.xml ├── docker-3-complex ├── microservice-provider-user │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── schema.sql │ │ │ ├── data.sql │ │ │ ├── application.yml │ │ │ ├── application-ha.yml.bak │ │ │ └── application-autherntication.yml.bak │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── ProviderUserApplication.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ └── entity │ │ │ └── User.java │ └── pom.xml ├── microservice-gateway-zuul │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── ZuulApplication.java │ └── pom.xml ├── microservice-consumer-movie-ribbon-hystrix │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ ├── ConsumerMovieApplication.java │ │ │ └── user │ │ │ ├── entity │ │ │ └── User.java │ │ │ └── controller │ │ │ └── MovieController.java │ └── pom.xml ├── microservice-hystrix-turbine │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── itmuch │ │ │ └── cloud │ │ │ └── study │ │ │ └── TurbineApplication.java │ └── pom.xml ├── microservice-discovery-eureka-ha │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itmuch │ │ │ │ └── cloud │ │ │ │ └── study │ │ │ │ └── EurekaApplication.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml ├── docker-compose.yml └── pom.xml ├── wx.jpg ├── .gitignore ├── elk ├── config │ └── logstash.conf └── docker-compose.yml ├── docker-2-eureka-ha ├── docker-compose.yml ├── microservice-discovery-eureka-ha │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── itmuch │ │ │ │ └── cloud │ │ │ │ └── study │ │ │ │ └── EurekaApplication.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml └── docker-compose-wrong.yml ├── README.md └── LICENSE /docker-host/microservice-provider-user/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /docker-host/microservice-hystrix-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8030 3 | -------------------------------------------------------------------------------- /wx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itmuch/spring-cloud-docker-microservice-book-code-docker/HEAD/wx.jpg -------------------------------------------------------------------------------- /docker-1-simple/microservice-hystrix-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8030 3 | -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | drop table user if exists; 2 | create table user (id bigint generated by default as identity, username varchar(40), name varchar(20), age int(3), balance decimal(10,2), primary key (id)); -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | drop table user if exists; 2 | create table user (id bigint generated by default as identity, username varchar(40), name varchar(20), age int(3), balance decimal(10,2), primary key (id)); -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | drop table user if exists; 2 | create table user (id bigint generated by default as identity, username varchar(40), name varchar(20), age int(3), balance decimal(10,2), primary key (id)); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | target/ 3 | 4 | 5 | # Eclipse project files 6 | .classpath 7 | .project 8 | .settings 9 | 10 | # IDEA metadata and output dirs 11 | *.iml 12 | *.ipr 13 | *.iws 14 | .idea/ 15 | 16 | # gitbook 17 | _book 18 | tmp 19 | .springBeans -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD microservice-discovery-eureka-0.0.1-SNAPSHOT.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 9000 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD microservice-discovery-eureka-0.0.1-SNAPSHOT.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 9000 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] -------------------------------------------------------------------------------- /docker-host/microservice-gateway-zuul/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8040 3 | spring: 4 | application: 5 | name: microservice-gateway-zuul 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://localhost:8761/eureka/ 10 | instance: 11 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-1-simple/microservice-gateway-zuul/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8040 3 | spring: 4 | application: 5 | name: microservice-gateway-zuul 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://discovery:8761/eureka/ 10 | instance: 11 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-1-simple/microservice-consumer-movie-ribbon-hystrix/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8010 3 | spring: 4 | application: 5 | name: microservice-consumer-movie 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://discovery:8761/eureka/ 10 | instance: 11 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-consumer-movie-ribbon-hystrix/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8010 3 | spring: 4 | application: 5 | name: microservice-consumer-movie 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8761/eureka/ 10 | instance: 11 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-3-complex/microservice-gateway-zuul/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8040 3 | spring: 4 | application: 5 | name: microservice-gateway-zuul 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 10 | instance: 11 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | insert into user (id, username, name, age, balance) values (1, 'account1', '张三', 20, 100.00); 2 | insert into user (id, username, name, age, balance) values (2, 'account2', '李四', 28, 180.00); 3 | insert into user (id, username, name, age, balance) values (3, 'account3', '王五', 32, 280.00); -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | insert into user (id, username, name, age, balance) values (1, 'account1', '张三', 20, 100.00); 2 | insert into user (id, username, name, age, balance) values (2, 'account2', '李四', 28, 180.00); 3 | insert into user (id, username, name, age, balance) values (3, 'account3', '王五', 32, 280.00); -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | insert into user (id, username, name, age, balance) values (1, 'account1', '张三', 20, 100.00); 2 | insert into user (id, username, name, age, balance) values (2, 'account2', '李四', 28, 180.00); 3 | insert into user (id, username, name, age, balance) values (3, 'account3', '王五', 32, 280.00); -------------------------------------------------------------------------------- /docker-3-complex/microservice-consumer-movie-ribbon-hystrix/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8010 3 | spring: 4 | application: 5 | name: microservice-consumer-movie 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 10 | instance: 11 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/java/com/itmuch/cloud/study/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.itmuch.cloud.study.entity.User; 7 | 8 | @Repository 9 | public interface UserRepository extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/java/com/itmuch/cloud/study/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.itmuch.cloud.study.entity.User; 7 | 8 | @Repository 9 | public interface UserRepository extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/java/com/itmuch/cloud/study/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.itmuch.cloud.study.entity.User; 7 | 8 | @Repository 9 | public interface UserRepository extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 # 指定该Eureka实例的端口 3 | eureka: 4 | client: 5 | registerWithEureka: false 6 | fetchRegistry: false 7 | serviceUrl: 8 | defaultZone: http://localhost:8761/eureka/ 9 | 10 | # 参考文档:http://projects.spring.io/spring-cloud/docs/1.0.3/spring-cloud.html#_standalone_mode 11 | # 参考文档:http://my.oschina.net/buwei/blog/618756 -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 # 指定该Eureka实例的端口 3 | eureka: 4 | client: 5 | registerWithEureka: false 6 | fetchRegistry: false 7 | serviceUrl: 8 | defaultZone: http://discovery:8761/eureka/ 9 | 10 | # 参考文档:http://projects.spring.io/spring-cloud/docs/1.0.3/spring-cloud.html#_standalone_mode 11 | # 参考文档:http://my.oschina.net/buwei/blog/618756 -------------------------------------------------------------------------------- /docker-host/microservice-hystrix-turbine/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8031 3 | spring: 4 | application: 5 | name: microservice-hystrix-turbine 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://localhost:8761/eureka/ 10 | instance: 11 | prefer-ip-address: true 12 | turbine: 13 | appConfig: microservice-consumer-movie,microservice-consumer-movie-feign-hystrix-fallback-stream 14 | clusterNameExpression: "'default'" -------------------------------------------------------------------------------- /docker-1-simple/microservice-hystrix-turbine/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8031 3 | spring: 4 | application: 5 | name: microservice-hystrix-turbine 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://discovery:8761/eureka/ 10 | instance: 11 | prefer-ip-address: true 12 | turbine: 13 | appConfig: microservice-consumer-movie,microservice-consumer-movie-feign-hystrix-fallback-stream 14 | clusterNameExpression: "'default'" -------------------------------------------------------------------------------- /elk/config/logstash.conf: -------------------------------------------------------------------------------- 1 | input { 2 | file { 3 | codec => json 4 | path => "/opt/build/*.json" 5 | } 6 | } 7 | filter { 8 | grok { 9 | match => { "message" => "%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:severity}\s+\[%{DATA:service},%{DATA:trace},%{DATA:span},%{DATA:exportable}\]\s+%{DATA:pid}---\s+\[%{DATA:thread}\]\s+%{DATA:class}\s+:\s+%{GREEDYDATA:rest}" } 10 | } 11 | } 12 | output { 13 | elasticsearch { 14 | hosts => "elasticsearch:9200" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-hystrix-turbine/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8031 3 | spring: 4 | application: 5 | name: microservice-hystrix-turbine 6 | eureka: 7 | client: 8 | service-url: 9 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 10 | instance: 11 | prefer-ip-address: true 12 | turbine: 13 | appConfig: microservice-consumer-movie,microservice-consumer-movie-feign-hystrix-fallback-stream 14 | clusterNameExpression: "'default'" -------------------------------------------------------------------------------- /docker-1-simple/microservice-gateway-zuul/src/main/java/com/itmuch/cloud/study/ZuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 6 | 7 | @SpringBootApplication 8 | @EnableZuulProxy 9 | public class ZuulApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ZuulApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-host/microservice-gateway-zuul/src/main/java/com/itmuch/cloud/study/ZuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 6 | 7 | @SpringBootApplication 8 | @EnableZuulProxy 9 | public class ZuulApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ZuulApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-gateway-zuul/src/main/java/com/itmuch/cloud/study/ZuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 6 | 7 | @SpringBootApplication 8 | @EnableZuulProxy 9 | public class ZuulApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ZuulApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-host/microservice-hystrix-turbine/src/main/java/com/itmuch/cloud/study/TurbineApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 6 | 7 | @SpringBootApplication 8 | @EnableTurbine 9 | public class TurbineApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(TurbineApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-hystrix-turbine/src/main/java/com/itmuch/cloud/study/TurbineApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 6 | 7 | @SpringBootApplication 8 | @EnableTurbine 9 | public class TurbineApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(TurbineApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-hystrix-turbine/src/main/java/com/itmuch/cloud/study/TurbineApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 6 | 7 | @SpringBootApplication 8 | @EnableTurbine 9 | public class TurbineApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(TurbineApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/java/com/itmuch/cloud/study/ProviderUserApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 ProviderUserApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ProviderUserApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/java/com/itmuch/cloud/study/ProviderUserApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 ProviderUserApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ProviderUserApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/java/com/itmuch/cloud/study/ProviderUserApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 ProviderUserApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(ProviderUserApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-2-eureka-ha/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | peer1: # 默认情况下,其他服务可使用服务名称连接到该服务。对于peer2节点,它需连接http://peer1:8761/eureka/,因此,我们可配置该服务的名称为peer1。 4 | image: itmuch/microservice-discovery-eureka-ha:0.0.1-SNAPSHOT 5 | ports: 6 | - "8761:8761" 7 | environment: 8 | - spring.profiles.active=peer1 9 | peer2: 10 | image: itmuch/microservice-discovery-eureka-ha:0.0.1-SNAPSHOT 11 | hostname: peer2 12 | ports: 13 | - "8762:8762" 14 | environment: 15 | - spring.profiles.active=peer2 16 | 17 | ## 使用Compose编排高可用的Eureka Server。 18 | -------------------------------------------------------------------------------- /docker-host/microservice-hystrix-dashboard/src/main/java/com/itmuch/cloud/study/HystrixDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 6 | 7 | @SpringBootApplication 8 | @EnableHystrixDashboard 9 | public class HystrixDashboardApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(HystrixDashboardApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-hystrix-dashboard/src/main/java/com/itmuch/cloud/study/HystrixDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 6 | 7 | @SpringBootApplication 8 | @EnableHystrixDashboard 9 | public class HystrixDashboardApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(HystrixDashboardApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/src/main/java/com/itmuch/cloud/study/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 | /** 8 | * 使用Eureka做服务发现. 9 | * @author 周立 10 | */ 11 | @SpringBootApplication 12 | @EnableEurekaServer 13 | public class EurekaApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(EurekaApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/src/main/java/com/itmuch/cloud/study/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 | /** 8 | * 使用Eureka做服务发现. 9 | * @author 周立 10 | */ 11 | @SpringBootApplication 12 | @EnableEurekaServer 13 | public class EurekaApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(EurekaApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-discovery-eureka-ha/src/main/java/com/itmuch/cloud/study/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 | /** 8 | * 使用Eureka做服务发现. 9 | * @author 周立 10 | */ 11 | @SpringBootApplication 12 | @EnableEurekaServer 13 | public class EurekaApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(EurekaApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docker-2-eureka-ha/microservice-discovery-eureka-ha/src/main/java/com/itmuch/cloud/study/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 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 | /** 8 | * 使用Eureka做服务发现. 9 | * @author 周立 10 | */ 11 | @SpringBootApplication 12 | @EnableEurekaServer 13 | public class EurekaApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(EurekaApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docker-2-eureka-ha/microservice-discovery-eureka-ha/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: microservice-discovery-eureka-ha 4 | --- 5 | spring: 6 | profiles: peer1 # 指定profile=peer1 7 | server: 8 | port: 8761 9 | eureka: 10 | instance: 11 | hostname: peer1 # 指定当profile=peer1时,主机名是peer1 12 | client: 13 | serviceUrl: 14 | defaultZone: http://peer2:8762/eureka/ # 将自己注册到peer2这个Eureka上面去 15 | 16 | --- 17 | spring: 18 | profiles: peer2 19 | server: 20 | port: 8762 21 | eureka: 22 | instance: 23 | hostname: peer2 24 | client: 25 | serviceUrl: 26 | defaultZone: http://peer1:8761/eureka/ -------------------------------------------------------------------------------- /docker-3-complex/microservice-discovery-eureka-ha/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: microservice-discovery-eureka-ha 4 | --- 5 | spring: 6 | profiles: peer1 # 指定profile=peer1 7 | server: 8 | port: 8761 9 | eureka: 10 | instance: 11 | hostname: peer1 # 指定当profile=peer1时,主机名是peer1 12 | client: 13 | serviceUrl: 14 | defaultZone: http://peer2:8762/eureka/ # 将自己注册到peer2这个Eureka上面去 15 | 16 | --- 17 | spring: 18 | profiles: peer2 19 | server: 20 | port: 8762 21 | eureka: 22 | instance: 23 | hostname: peer2 24 | client: 25 | serviceUrl: 26 | defaultZone: http://peer1:8761/eureka/ -------------------------------------------------------------------------------- /elk/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | elasticsearch: 4 | image: docker.elastic.co/elasticsearch/elasticsearch:6.1.1 5 | command: elasticsearch 6 | ports: 7 | - "9200:9200" 8 | - "9300:9300" 9 | logstash: 10 | image: docker.elastic.co/logstash/logstash:6.1.1 11 | command: logstash -f /etc/logstash/conf.d/logstash.conf 12 | volumes: 13 | # 挂载logstash配置文件 14 | - ./config:/etc/logstash/conf.d 15 | - /Users/apple/develop/code/GIT_CHECK/my/spring-cloud-docker-microservice-book-code/trace/build/:/opt/build/ 16 | ports: 17 | - "5000:5000" 18 | kibana: 19 | image: docker.elastic.co/kibana/kibana:6.1.1 20 | environment: 21 | - ELASTICSEARCH_URL=http://elasticsearch:9200 22 | ports: 23 | - "5601:5601" -------------------------------------------------------------------------------- /docker-1-simple/docker-compose-easy.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | discovery: 4 | image: itmuch/microservice-discovery-eureka:0.0.1-SNAPSHOT 5 | ports: 6 | - "8761:8761" 7 | microservice-provider-user: 8 | image: itmuch/microservice-provider-user:0.0.1-SNAPSHOT 9 | microservice-consumer-movie-ribbon-hystrix: 10 | image: itmuch/microservice-consumer-movie-ribbon-hystrix:0.0.1-SNAPSHOT 11 | microservice-gateway-zuul: 12 | image: itmuch/microservice-gateway-zuul:0.0.1-SNAPSHOT 13 | microservice-hystrix-dashboard: 14 | image: itmuch/microservice-hystrix-dashboard:0.0.1-SNAPSHOT 15 | microservice-hystrix-turbine: 16 | image: itmuch/microservice-hystrix-turbine:0.0.1-SNAPSHOT 17 | 18 | # 最简单的配置方式,等价于docker-compose.yml。 -------------------------------------------------------------------------------- /docker-2-eureka-ha/docker-compose-wrong.yml: -------------------------------------------------------------------------------- 1 | version: "3" # 表示使用docker-compose.yml的Version 3 file format编写 2 | services: 3 | microservice-discovery-eureka-ha1: 4 | hostname: peer1 # 指定hostname 5 | image: itmuch/microservice-discovery-eureka-ha:0.0.1-SNAPSHOT 6 | links: 7 | - microservice-discovery-eureka-ha2 8 | ports: 9 | - "8761:8761" 10 | environment: 11 | - spring.profiles.active=peer1 12 | microservice-discovery-eureka-ha2: 13 | hostname: peer2 14 | image: itmuch/microservice-discovery-eureka-ha:0.0.1-SNAPSHOT 15 | links: 16 | - microservice-discovery-eureka-ha1 17 | ports: 18 | - "8762:8762" 19 | environment: 20 | - spring.profiles.active=peer2 21 | 22 | ## 该文件是最自然的写法,但无法正常使用。运行docker-compose up时,会报循环依赖的异常。 -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/java/com/itmuch/cloud/study/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import com.itmuch.cloud.study.entity.User; 9 | import com.itmuch.cloud.study.repository.UserRepository; 10 | 11 | @RestController 12 | public class UserController { 13 | @Autowired 14 | private UserRepository userRepository; 15 | 16 | @GetMapping("/{id}") 17 | public User findById(@PathVariable Long id) { 18 | User findOne = this.userRepository.findOne(id); 19 | return findOne; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/java/com/itmuch/cloud/study/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import com.itmuch.cloud.study.entity.User; 9 | import com.itmuch.cloud.study.repository.UserRepository; 10 | 11 | @RestController 12 | public class UserController { 13 | @Autowired 14 | private UserRepository userRepository; 15 | 16 | @GetMapping("/{id}") 17 | public User findById(@PathVariable Long id) { 18 | User findOne = this.userRepository.findOne(id); 19 | return findOne; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/java/com/itmuch/cloud/study/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import com.itmuch.cloud.study.entity.User; 9 | import com.itmuch.cloud.study.repository.UserRepository; 10 | 11 | @RestController 12 | public class UserController { 13 | @Autowired 14 | private UserRepository userRepository; 15 | 16 | @GetMapping("/{id}") 17 | public User findById(@PathVariable Long id) { 18 | User findOne = this.userRepository.findOne(id); 19 | return findOne; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docker-3-complex/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | peer1: 4 | image: itmuch/microservice-discovery-eureka-ha:0.0.1-SNAPSHOT 5 | ports: 6 | - "8761:8761" 7 | environment: 8 | - spring.profiles.active=peer1 9 | peer2: 10 | image: itmuch/microservice-discovery-eureka-ha:0.0.1-SNAPSHOT 11 | hostname: peer2 12 | ports: 13 | - "8762:8762" 14 | environment: 15 | - spring.profiles.active=peer2 16 | microservice-provider-user: 17 | image: itmuch/microservice-provider-user:0.0.1-SNAPSHOT 18 | microservice-consumer-movie-ribbon-hystrix: 19 | image: itmuch/microservice-consumer-movie-ribbon-hystrix:0.0.1-SNAPSHOT 20 | microservice-gateway-zuul: 21 | image: itmuch/microservice-gateway-zuul:0.0.1-SNAPSHOT 22 | microservice-hystrix-turbine: 23 | image: itmuch/microservice-hystrix-turbine:0.0.1-SNAPSHOT -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://discovery:8761/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://localhost:8761/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/resources/application-ha.yml.bak: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/resources/application-ha.yml.bak: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/resources/application-ha.yml.bak: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/resources/application-autherntication.yml.bak: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://user:password123@localhost:8761/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/resources/application-autherntication.yml.bak: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://user:password123@localhost:8761/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/resources/application-autherntication.yml.bak: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8000 3 | spring: 4 | application: 5 | name: microservice-provider-user 6 | jpa: 7 | generate-ddl: false 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: none 11 | datasource: # 指定数据源 12 | platform: h2 # 指定数据源类型 13 | schema: classpath:schema.sql # 指定h2数据库的建表脚本 14 | data: classpath:data.sql # 指定h2数据库的insert脚本 15 | logging: # 配置日志级别,让hibernate打印出执行的SQL 16 | level: 17 | root: INFO 18 | org.hibernate: INFO 19 | org.hibernate.type.descriptor.sql.BasicBinder: TRACE 20 | org.hibernate.type.descriptor.sql.BasicExtractor: TRACE 21 | eureka: 22 | client: 23 | serviceUrl: 24 | defaultZone: http://user:password123@localhost:8761/eureka/ 25 | instance: 26 | prefer-ip-address: true -------------------------------------------------------------------------------- /docker-host/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/ConsumerMovieApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | @EnableDiscoveryClient 12 | @SpringBootApplication 13 | @EnableCircuitBreaker 14 | public class ConsumerMovieApplication { 15 | @Bean 16 | @LoadBalanced 17 | public RestTemplate restTemplate() { 18 | return new RestTemplate(); 19 | } 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(ConsumerMovieApplication.class, args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/ConsumerMovieApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | @EnableDiscoveryClient 12 | @SpringBootApplication 13 | @EnableCircuitBreaker 14 | public class ConsumerMovieApplication { 15 | @Bean 16 | @LoadBalanced 17 | public RestTemplate restTemplate() { 18 | return new RestTemplate(); 19 | } 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(ConsumerMovieApplication.class, args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/ConsumerMovieApplication.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | @EnableDiscoveryClient 12 | @SpringBootApplication 13 | @EnableCircuitBreaker 14 | public class ConsumerMovieApplication { 15 | @Bean 16 | @LoadBalanced 17 | public RestTemplate restTemplate() { 18 | return new RestTemplate(); 19 | } 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(ConsumerMovieApplication.class, args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 《Spring Cloud与Docker微服务架构实战 第二版》Docker章节(12-14章)配套代码 2 | 3 | - 本Repo是《Spring Cloud与Docker微服务架构实战 **第二版**》Docker章节(12-14章)的配套代码,**第一版**的配套源码详见Camden分支。 4 | - 所有Docker Compose采用Version 3 file format编写。 5 | - 1-11章配套代码详见: 6 | 7 | 8 | 9 | 10 | ## 交流 11 | 12 | - QQ群:731548893,欢迎加入 13 | - 个人博客:[http://www.itmuch.com](http://www.itmuch.com) 14 | - 微信:![微信公众号](wx.jpg) 15 | 16 | 17 | **持续更新Spring Cloud、Docker相关知识**,敬请关注!! 18 | 19 | 20 | 21 | 22 | ## 目录说明 23 | 24 | #### 一、docker-1-simple 25 | 26 | * 使用Maven的Docker插件构建Docker镜像。详见其中的microservice-discovery-eureka目录。 27 | * 使用Docker Compose编排Spring Cloud微服务。 28 | 29 | 30 | 31 | #### 二、docker-2-eureka-ha 32 | 33 | * 使用Docker Compose编排高可用的Eureka Server 34 | 35 | 36 | 37 | #### 三、docker-3-complex 38 | 39 | * 综合示例,使用Docker Compose编排Spring Cloud微服务体系,并实现动态伸缩。 40 | 41 | 42 | #### 四、docker-host 43 | 44 | 使用Docker Compose编排Spring Cloud微服务,使用host网络模式。该方式不适合生产,实体书里也没写。仅供参考、把玩。 45 | 46 | #### 五、ELK 47 | 48 | 在第十一章用到ELK,考虑到对ELK不熟悉的朋友们,提供ELK的Compose文件。 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /docker-host/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/user/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.user.entity; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class User { 6 | private Long id; 7 | private String username; 8 | private String name; 9 | private Integer age; 10 | private BigDecimal balance; 11 | 12 | public Long getId() { 13 | return this.id; 14 | } 15 | 16 | public void setId(Long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getUsername() { 21 | return this.username; 22 | } 23 | 24 | public void setUsername(String username) { 25 | this.username = username; 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public Integer getAge() { 37 | return this.age; 38 | } 39 | 40 | public void setAge(Integer age) { 41 | this.age = age; 42 | } 43 | 44 | public BigDecimal getBalance() { 45 | return this.balance; 46 | } 47 | 48 | public void setBalance(BigDecimal balance) { 49 | this.balance = balance; 50 | } 51 | } -------------------------------------------------------------------------------- /docker-1-simple/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/user/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.user.entity; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class User { 6 | private Long id; 7 | private String username; 8 | private String name; 9 | private Integer age; 10 | private BigDecimal balance; 11 | 12 | public Long getId() { 13 | return this.id; 14 | } 15 | 16 | public void setId(Long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getUsername() { 21 | return this.username; 22 | } 23 | 24 | public void setUsername(String username) { 25 | this.username = username; 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public Integer getAge() { 37 | return this.age; 38 | } 39 | 40 | public void setAge(Integer age) { 41 | this.age = age; 42 | } 43 | 44 | public BigDecimal getBalance() { 45 | return this.balance; 46 | } 47 | 48 | public void setBalance(BigDecimal balance) { 49 | this.balance = balance; 50 | } 51 | } -------------------------------------------------------------------------------- /docker-3-complex/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/user/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.user.entity; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class User { 6 | private Long id; 7 | private String username; 8 | private String name; 9 | private Integer age; 10 | private BigDecimal balance; 11 | 12 | public Long getId() { 13 | return this.id; 14 | } 15 | 16 | public void setId(Long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getUsername() { 21 | return this.username; 22 | } 23 | 24 | public void setUsername(String username) { 25 | this.username = username; 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public Integer getAge() { 37 | return this.age; 38 | } 39 | 40 | public void setAge(Integer age) { 41 | this.age = age; 42 | } 43 | 44 | public BigDecimal getBalance() { 45 | return this.balance; 46 | } 47 | 48 | public void setBalance(BigDecimal balance) { 49 | this.balance = balance; 50 | } 51 | } -------------------------------------------------------------------------------- /docker-host/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | microservice-discovery-eureka: 4 | image: itmuch/microservice-discovery-eureka:0.0.1-SNAPSHOT 5 | network_mode: host 6 | ports: 7 | - 8761:8761 8 | microservice-provider-user: 9 | image: itmuch/microservice-provider-user:0.0.1-SNAPSHOT 10 | network_mode: host 11 | ports: 12 | - 8000:8000 13 | microservice-consumer-movie-ribbon-hystrix: 14 | image: itmuch/microservice-consumer-movie-ribbon-hystrix:0.0.1-SNAPSHOT 15 | network_mode: host 16 | ports: 17 | - 8010:8010 18 | microservice-hystrix-dashboard: 19 | image: itmuch/microservice-hystrix-dashboard:0.0.1-SNAPSHOT 20 | network_mode: host 21 | ports: 22 | - 8030:8030 23 | microservice-hystrix-turbine: 24 | image: itmuch/microservice-hystrix-turbine:0.0.1-SNAPSHOT 25 | network_mode: host 26 | ports: 27 | - 8031:8031 28 | microservice-gateway-zuul: 29 | image: itmuch/microservice-gateway-zuul:0.0.1-SNAPSHOT 30 | network_mode: host 31 | ports: 32 | - 8040:8040 33 | 34 | ## 注1:本Compose文件使用的网络模式是host,使用这种模式,可以让所有的微服务都无需修改eureka.client.serviceUrl.defautlZone的配置,而直接使用http://localhost:8761/eureka/。 35 | ## 注2:该方式一般不适合生产,实体书里也并未提及,仅作拓展阅读。 -------------------------------------------------------------------------------- /docker-1-simple/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' # 表示该docker-compose.yml文件使用的是Version 2 file format 2 | services: # Version 2 file format的固定写法,为project定义服务。 3 | microservice-discovery-eureka: # 指定服务名称 4 | image: itmuch/microservice-discovery-eureka:0.0.1-SNAPSHOT # 指定服务所使用的镜像 5 | ports: # 暴露端口信息 6 | - "8761:8761" 7 | microservice-provider-user: 8 | image: itmuch/microservice-provider-user:0.0.1-SNAPSHOT 9 | links: # 链接到microservice-discovery-eureka,这边使用的是SERVICE:ALIAS的形式 10 | - microservice-discovery-eureka:discovery 11 | microservice-consumer-movie-ribbon-hystrix: 12 | image: itmuch/microservice-consumer-movie-ribbon-hystrix:0.0.1-SNAPSHOT 13 | links: 14 | - microservice-discovery-eureka:discovery 15 | microservice-gateway-zuul: 16 | image: itmuch/microservice-gateway-zuul:0.0.1-SNAPSHOT 17 | links: 18 | - microservice-discovery-eureka:discovery 19 | microservice-hystrix-dashboard: 20 | image: itmuch/microservice-hystrix-dashboard:0.0.1-SNAPSHOT 21 | links: 22 | - microservice-discovery-eureka:discovery 23 | microservice-hystrix-turbine: 24 | image: itmuch/microservice-hystrix-turbine:0.0.1-SNAPSHOT 25 | links: 26 | - microservice-discovery-eureka:discovery -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/src/main/java/com/itmuch/cloud/study/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.entity; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | 11 | @Entity 12 | public class User { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.AUTO) 15 | private Long id; 16 | @Column 17 | private String username; 18 | @Column 19 | private String name; 20 | @Column 21 | private Integer age; 22 | @Column 23 | private BigDecimal balance; 24 | 25 | public Long getId() { 26 | return this.id; 27 | } 28 | 29 | public void setId(Long id) { 30 | this.id = id; 31 | } 32 | 33 | public String getUsername() { 34 | return this.username; 35 | } 36 | 37 | public void setUsername(String username) { 38 | this.username = username; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public Integer getAge() { 50 | return this.age; 51 | } 52 | 53 | public void setAge(Integer age) { 54 | this.age = age; 55 | } 56 | 57 | public BigDecimal getBalance() { 58 | return this.balance; 59 | } 60 | 61 | public void setBalance(BigDecimal balance) { 62 | this.balance = balance; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/src/main/java/com/itmuch/cloud/study/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.entity; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | 11 | @Entity 12 | public class User { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.AUTO) 15 | private Long id; 16 | @Column 17 | private String username; 18 | @Column 19 | private String name; 20 | @Column 21 | private Integer age; 22 | @Column 23 | private BigDecimal balance; 24 | 25 | public Long getId() { 26 | return this.id; 27 | } 28 | 29 | public void setId(Long id) { 30 | this.id = id; 31 | } 32 | 33 | public String getUsername() { 34 | return this.username; 35 | } 36 | 37 | public void setUsername(String username) { 38 | this.username = username; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public Integer getAge() { 50 | return this.age; 51 | } 52 | 53 | public void setAge(Integer age) { 54 | this.age = age; 55 | } 56 | 57 | public BigDecimal getBalance() { 58 | return this.balance; 59 | } 60 | 61 | public void setBalance(BigDecimal balance) { 62 | this.balance = balance; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/src/main/java/com/itmuch/cloud/study/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.entity; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | 11 | @Entity 12 | public class User { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.AUTO) 15 | private Long id; 16 | @Column 17 | private String username; 18 | @Column 19 | private String name; 20 | @Column 21 | private Integer age; 22 | @Column 23 | private BigDecimal balance; 24 | 25 | public Long getId() { 26 | return this.id; 27 | } 28 | 29 | public void setId(Long id) { 30 | this.id = id; 31 | } 32 | 33 | public String getUsername() { 34 | return this.username; 35 | } 36 | 37 | public void setUsername(String username) { 38 | this.username = username; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public Integer getAge() { 50 | return this.age; 51 | } 52 | 53 | public void setAge(Integer age) { 54 | this.age = age; 55 | } 56 | 57 | public BigDecimal getBalance() { 58 | return this.balance; 59 | } 60 | 61 | public void setBalance(BigDecimal balance) { 62 | this.balance = balance; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /docker-3-complex/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | parent 7 | 0.0.1-SNAPSHOT 8 | pom 9 | 10 | 11 | microservice-consumer-movie-ribbon-hystrix 12 | microservice-discovery-eureka-ha 13 | microservice-gateway-zuul 14 | microservice-hystrix-turbine 15 | microservice-provider-user 16 | 17 | 18 | 19 | 20 | 21 | 22 | com.spotify 23 | docker-maven-plugin 24 | 0.4.13 25 | 26 | itmuch/${project.artifactId}:${project.version} 27 | true 28 | java 29 | ["java", "-jar", "/${project.build.finalName}.jar"] 30 | 31 | 32 | / 33 | ${project.build.directory} 34 | ${project.build.finalName}.jar 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docker-host/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | parent 7 | 0.0.1-SNAPSHOT 8 | pom 9 | 10 | 11 | microservice-consumer-movie-ribbon-hystrix 12 | microservice-discovery-eureka 13 | microservice-gateway-zuul 14 | microservice-hystrix-dashboard 15 | microservice-hystrix-turbine 16 | microservice-provider-user 17 | 18 | 19 | 20 | 21 | 22 | 23 | com.spotify 24 | docker-maven-plugin 25 | 0.4.13 26 | 27 | itmuch/${project.artifactId}:${project.version} 28 | java 29 | ["java", "-jar", "/${project.build.finalName}.jar"] 30 | 31 | 32 | / 33 | ${project.build.directory} 34 | ${project.build.finalName}.jar 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docker-1-simple/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | parent 7 | 0.0.1-SNAPSHOT 8 | pom 9 | 10 | 11 | microservice-consumer-movie-ribbon-hystrix 12 | microservice-discovery-eureka 13 | microservice-gateway-zuul 14 | microservice-hystrix-dashboard 15 | microservice-hystrix-turbine 16 | microservice-provider-user 17 | 18 | 19 | 20 | 21 | 22 | 23 | com.spotify 24 | docker-maven-plugin 25 | 0.4.13 26 | 27 | itmuch/${project.artifactId}:${project.version} 28 | java 29 | ["java", "-jar", "/${project.build.finalName}.jar"] 30 | 31 | 32 | / 33 | ${project.build.directory} 34 | ${project.build.finalName}.jar 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docker-host/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/user/controller/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.user.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cloud.client.ServiceInstance; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | import com.itmuch.cloud.study.user.entity.User; 14 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 15 | 16 | @RestController 17 | public class MovieController { 18 | private static final Logger LOGGER = LoggerFactory.getLogger(MovieController.class); 19 | @Autowired 20 | private RestTemplate restTemplate; 21 | @Autowired 22 | private LoadBalancerClient loadBalancerClient; 23 | 24 | @HystrixCommand(fallbackMethod = "findByIdFallback") 25 | @GetMapping("/user/{id}") 26 | public User findById(@PathVariable Long id) { 27 | return this.restTemplate.getForObject("http://microservice-provider-user/" + id, User.class); 28 | } 29 | 30 | public User findByIdFallback(Long id) { 31 | User user = new User(); 32 | user.setId(-1L); 33 | user.setName("默认用户"); 34 | return user; 35 | } 36 | 37 | @GetMapping("/log-user-instance") 38 | public void logUserInstance() { 39 | ServiceInstance serviceInstance = this.loadBalancerClient.choose("microservice-provider-user"); 40 | // 打印当前选择的是哪个节点 41 | MovieController.LOGGER.info("{}:{}:{}", serviceInstance.getServiceId(), serviceInstance.getHost(), serviceInstance.getPort()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/user/controller/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.user.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cloud.client.ServiceInstance; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | import com.itmuch.cloud.study.user.entity.User; 14 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 15 | 16 | @RestController 17 | public class MovieController { 18 | private static final Logger LOGGER = LoggerFactory.getLogger(MovieController.class); 19 | @Autowired 20 | private RestTemplate restTemplate; 21 | @Autowired 22 | private LoadBalancerClient loadBalancerClient; 23 | 24 | @HystrixCommand(fallbackMethod = "findByIdFallback") 25 | @GetMapping("/user/{id}") 26 | public User findById(@PathVariable Long id) { 27 | return this.restTemplate.getForObject("http://microservice-provider-user/" + id, User.class); 28 | } 29 | 30 | public User findByIdFallback(Long id) { 31 | User user = new User(); 32 | user.setId(-1L); 33 | user.setName("默认用户"); 34 | return user; 35 | } 36 | 37 | @GetMapping("/log-user-instance") 38 | public void logUserInstance() { 39 | ServiceInstance serviceInstance = this.loadBalancerClient.choose("microservice-provider-user"); 40 | // 打印当前选择的是哪个节点 41 | MovieController.LOGGER.info("{}:{}:{}", serviceInstance.getServiceId(), serviceInstance.getHost(), serviceInstance.getPort()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-consumer-movie-ribbon-hystrix/src/main/java/com/itmuch/cloud/study/user/controller/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.itmuch.cloud.study.user.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cloud.client.ServiceInstance; 7 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | import com.itmuch.cloud.study.user.entity.User; 14 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 15 | 16 | @RestController 17 | public class MovieController { 18 | private static final Logger LOGGER = LoggerFactory.getLogger(MovieController.class); 19 | @Autowired 20 | private RestTemplate restTemplate; 21 | @Autowired 22 | private LoadBalancerClient loadBalancerClient; 23 | 24 | @HystrixCommand(fallbackMethod = "findByIdFallback") 25 | @GetMapping("/user/{id}") 26 | public User findById(@PathVariable Long id) { 27 | return this.restTemplate.getForObject("http://microservice-provider-user/" + id, User.class); 28 | } 29 | 30 | public User findByIdFallback(Long id) { 31 | User user = new User(); 32 | user.setId(-1L); 33 | user.setName("默认用户"); 34 | return user; 35 | } 36 | 37 | @GetMapping("/log-user-instance") 38 | public void logUserInstance() { 39 | ServiceInstance serviceInstance = this.loadBalancerClient.choose("microservice-provider-user"); 40 | // 打印当前选择的是哪个节点 41 | MovieController.LOGGER.info("{}:{}:{}", serviceInstance.getServiceId(), serviceInstance.getHost(), serviceInstance.getPort()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/pom.xml.bak2-指定Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/microservice-discovery-eureka:0.0.2 57 | ${project.basedir}/src/main/docker 58 | 59 | 60 | / 61 | ${project.build.directory} 62 | ${project.build.finalName}.jar 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/pom.xml.bak2-指定Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/microservice-discovery-eureka:0.0.2 57 | ${project.basedir}/src/main/docker 58 | 59 | 60 | / 61 | ${project.build.directory} 62 | ${project.build.finalName}.jar 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /docker-host/microservice-hystrix-turbine/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-hystrix-turbine 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-turbine 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | java 58 | ["java", "-jar", "/${project.build.finalName}.jar"] 59 | 60 | 61 | / 62 | ${project.build.directory} 63 | ${project.build.finalName}.jar 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-hystrix-turbine/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-hystrix-turbine 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-turbine 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | java 58 | ["java", "-jar", "/${project.build.finalName}.jar"] 59 | 60 | 61 | / 62 | ${project.build.directory} 63 | ${project.build.finalName}.jar 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-hystrix-dashboard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-hystrix-dashboard 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-hystrix-dashboard 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | java 58 | ["java", "-jar", "/${project.build.finalName}.jar"] 59 | 60 | 61 | / 62 | ${project.build.directory} 63 | ${project.build.finalName}.jar 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | com.spotify 54 | docker-maven-plugin 55 | 0.4.13 56 | 57 | itmuch/${project.artifactId}:${project.version} 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-host/microservice-hystrix-dashboard/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-hystrix-dashboard 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-hystrix-dashboard 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | java 58 | ["java", "-jar", "/${project.build.finalName}.jar"] 59 | 60 | 61 | / 62 | ${project.build.directory} 63 | ${project.build.finalName}.jar 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | com.spotify 54 | docker-maven-plugin 55 | 0.4.13 56 | 57 | itmuch/${project.artifactId}:${project.version} 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/pom.xml-bak1-快速入门,最简单的示例: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | com.spotify 54 | docker-maven-plugin 55 | 0.4.13 56 | 57 | itmuch/microservice-discovery-eureka:0.0.1 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/pom.xml-bak1-快速入门,最简单的示例: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | com.spotify 54 | docker-maven-plugin 55 | 0.4.13 56 | 57 | itmuch/microservice-discovery-eureka:0.0.1 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-hystrix-turbine/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-hystrix-turbine 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-turbine 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | true 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-discovery-eureka-ha/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka-ha 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | true 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-2-eureka-ha/microservice-discovery-eureka-ha/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka-ha 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Edgware.RELEASE 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/${project.artifactId}:${project.version} 57 | true 58 | java 59 | ["java", "-jar", "/${project.build.finalName}.jar"] 60 | 61 | 62 | / 63 | ${project.build.directory} 64 | ${project.build.finalName}.jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/pom.xml.bak4-推送镜像到Docker Hub: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/microservice-discovery-eureka:0.0.4 57 | java 58 | ["java", "-jar", "/${project.build.finalName}.jar"] 59 | 60 | 61 | / 62 | ${project.build.directory} 63 | ${project.build.finalName}.jar 64 | 65 | 66 | 67 | 68 | docker-hub 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/pom.xml.bak4-推送镜像到Docker Hub: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/microservice-discovery-eureka:0.0.4 57 | java 58 | ["java", "-jar", "/${project.build.finalName}.jar"] 59 | 60 | 61 | / 62 | ${project.build.directory} 63 | ${project.build.finalName}.jar 64 | 65 | 66 | 67 | 68 | docker-hub 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/pom.xml.bak5-使用imageTags指定标签: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/microservice-discovery-eureka 57 | 58 | 59 | 0.0.5 60 | latest 61 | 62 | java 63 | ["java", "-jar", "/${project.build.finalName}.jar"] 64 | 65 | 66 | / 67 | ${project.build.directory} 68 | ${project.build.finalName}.jar 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /docker-host/microservice-gateway-zuul/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-gateway-zuul 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-zuul 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-dependencies 39 | Edgware.RELEASE 40 | pom 41 | import 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-maven-plugin 52 | 53 | 54 | 55 | 56 | com.spotify 57 | docker-maven-plugin 58 | 0.4.13 59 | 60 | itmuch/${project.artifactId}:${project.version} 61 | java 62 | ["java", "-jar", "/${project.build.finalName}.jar"] 63 | 64 | 65 | / 66 | ${project.build.directory} 67 | ${project.build.finalName}.jar 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/pom.xml.bak5-使用imageTags指定标签: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | itmuch/microservice-discovery-eureka 57 | 58 | 59 | 0.0.5 60 | latest 61 | 62 | java 63 | ["java", "-jar", "/${project.build.finalName}.jar"] 64 | 65 | 66 | / 67 | ${project.build.directory} 68 | ${project.build.finalName}.jar 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-gateway-zuul/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-gateway-zuul 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-zuul 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-dependencies 39 | Edgware.RELEASE 40 | pom 41 | import 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-maven-plugin 52 | 53 | 54 | 55 | 56 | com.spotify 57 | docker-maven-plugin 58 | 0.4.13 59 | 60 | itmuch/${project.artifactId}:${project.version} 61 | java 62 | ["java", "-jar", "/${project.build.finalName}.jar"] 63 | 64 | 65 | / 66 | ${project.build.directory} 67 | ${project.build.finalName}.jar 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-gateway-zuul/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-gateway-zuul 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-zuul 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-dependencies 39 | Edgware.RELEASE 40 | pom 41 | import 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-maven-plugin 52 | 53 | 54 | 55 | 56 | com.spotify 57 | docker-maven-plugin 58 | 0.4.13 59 | 60 | itmuch/${project.artifactId}:${project.version} 61 | true 62 | java 63 | ["java", "-jar", "/${project.build.finalName}.jar"] 64 | 65 | 66 | / 67 | ${project.build.directory} 68 | ${project.build.finalName}.jar 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /docker-host/microservice-discovery-eureka/pom.xml.bak3-绑定某个phase运行: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | 57 | build-image 58 | package 59 | 60 | build 61 | 62 | 63 | 64 | 65 | itmuch/microservice-discovery-eureka:0.0.3 66 | java 67 | ["java", "-jar", "/${project.build.finalName}.jar"] 68 | 69 | 70 | / 71 | ${project.build.directory} 72 | ${project.build.finalName}.jar 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-discovery-eureka/pom.xml.bak3-绑定某个phase运行: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-discovery-eureka 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-dependencies 35 | Camden.SR2 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | com.spotify 53 | docker-maven-plugin 54 | 0.4.13 55 | 56 | 57 | build-image 58 | package 59 | 60 | build 61 | 62 | 63 | 64 | 65 | itmuch/microservice-discovery-eureka:0.0.3 66 | java 67 | ["java", "-jar", "/${project.build.finalName}.jar"] 68 | 69 | 70 | / 71 | ${project.build.directory} 72 | ${project.build.finalName}.jar 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /docker-host/microservice-consumer-movie-ribbon-hystrix/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-consumer-movie-ribbon-hystrix 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-netflix-eureka-client 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-netflix-hystrix 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-dependencies 49 | Edgware.RELEASE 50 | pom 51 | import 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | com.spotify 67 | docker-maven-plugin 68 | 0.4.13 69 | 70 | itmuch/${project.artifactId}:${project.version} 71 | java 72 | ["java", "-jar", "/${project.build.finalName}.jar"] 73 | 74 | 75 | / 76 | ${project.build.directory} 77 | ${project.build.finalName}.jar 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-consumer-movie-ribbon-hystrix/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-consumer-movie-ribbon-hystrix 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-netflix-eureka-client 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-netflix-hystrix 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-dependencies 49 | Edgware.RELEASE 50 | pom 51 | import 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | com.spotify 67 | docker-maven-plugin 68 | 0.4.13 69 | 70 | itmuch/${project.artifactId}:${project.version} 71 | java 72 | ["java", "-jar", "/${project.build.finalName}.jar"] 73 | 74 | 75 | / 76 | ${project.build.directory} 77 | ${project.build.finalName}.jar 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-consumer-movie-ribbon-hystrix/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-consumer-movie-ribbon-hystrix 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-netflix-eureka-client 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-netflix-hystrix 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-dependencies 49 | Edgware.RELEASE 50 | pom 51 | import 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | com.spotify 67 | docker-maven-plugin 68 | 0.4.13 69 | 70 | itmuch/${project.artifactId}:${project.version} 71 | true 72 | java 73 | ["java", "-jar", "/${project.build.finalName}.jar"] 74 | 75 | 76 | / 77 | ${project.build.directory} 78 | ${project.build.finalName}.jar 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docker-host/microservice-provider-user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-provider-user 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | com.h2database 33 | h2 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-actuator 38 | 39 | 40 | 41 | org.springframework.cloud 42 | spring-cloud-starter-netflix-eureka-client 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.cloud 51 | spring-cloud-dependencies 52 | Edgware.RELEASE 53 | pom 54 | import 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | com.spotify 70 | docker-maven-plugin 71 | 0.4.13 72 | 73 | itmuch/${project.artifactId}:${project.version} 74 | java 75 | ["java", "-jar", "/${project.build.finalName}.jar"] 76 | 77 | 78 | / 79 | ${project.build.directory} 80 | ${project.build.finalName}.jar 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /docker-1-simple/microservice-provider-user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-provider-user 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | com.h2database 33 | h2 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-actuator 38 | 39 | 40 | 41 | org.springframework.cloud 42 | spring-cloud-starter-netflix-eureka-client 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.cloud 51 | spring-cloud-dependencies 52 | Edgware.RELEASE 53 | pom 54 | import 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | com.spotify 70 | docker-maven-plugin 71 | 0.4.13 72 | 73 | itmuch/${project.artifactId}:${project.version} 74 | java 75 | ["java", "-jar", "/${project.build.finalName}.jar"] 76 | 77 | 78 | / 79 | ${project.build.directory} 80 | ${project.build.finalName}.jar 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /docker-3-complex/microservice-provider-user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.itmuch.cloud 6 | microservice-provider-user 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.9.RELEASE 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | com.h2database 33 | h2 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-actuator 38 | 39 | 40 | 41 | org.springframework.cloud 42 | spring-cloud-starter-netflix-eureka-client 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.cloud 51 | spring-cloud-dependencies 52 | Edgware.RELEASE 53 | pom 54 | import 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | com.spotify 70 | docker-maven-plugin 71 | 0.4.13 72 | 73 | itmuch/${project.artifactId}:${project.version} 74 | true 75 | java 76 | ["java", "-jar", "/${project.build.finalName}.jar"] 77 | 78 | 79 | / 80 | ${project.build.directory} 81 | ${project.build.finalName}.jar 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "{}" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright 2016 ITMUCH 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. --------------------------------------------------------------------------------