├── .gitignore
├── LICENSE
├── README.md
├── chapter1
├── eureka-server
│ ├── .springBeans
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── jeegem
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ ├── application.yml
│ │ │ └── logback.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
└── service-hi
│ ├── .springBeans
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── jeegem
│ │ │ └── ServiceHiApplication.java
│ └── resources
│ │ └── bootstrap.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceHiApplicationTests.java
├── chapter10
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── eureka-server2
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── eureka-server3
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
└── service-hi
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ └── ServiceHiApplication.java
│ └── resources
│ │ └── bootstrap.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceHiApplicationTests.java
├── chapter11-2
├── docker-compose-dev.yml
├── docker-compose.yml
├── eureka-server
│ ├── Dockerfile
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
└── service-hi
│ ├── Dockerfile
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ └── ServiceHiApplication.java
│ └── resources
│ │ └── bootstrap.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceHiApplicationTests.java
├── chapter11
├── docker-compose-dev.yml
├── docker-compose.yml
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── docker
│ │ │ └── Dockerfile
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
└── service-hi
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── docker
│ │ └── Dockerfile
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ └── ServiceHiApplication.java
│ └── resources
│ │ └── bootstrap.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceHiApplicationTests.java
├── chapter12
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
└── service-hi
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ └── ServiceHiApplication.java
│ └── resources
│ │ └── bootstrap.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceHiApplicationTests.java
├── chapter13
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
├── service-hi
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
├── service-lucy
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceLucyApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceLucyApplicationTests.java
└── service-turbine
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ └── ServiceTurbineApplication.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceTurbineApplicationTests.java
├── chapter14
├── consul-miya
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConsulMiyaApplication.java
│ │ └── resources
│ │ │ ├── bootstrap.yml
│ │ │ └── logback.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConsulMiyaApplicationTests.java
└── pom.xml
├── chapter2
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
├── service-hi-8762
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
├── service-hi
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
└── service-ribbon
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ ├── ServiceRibbonApplication.java
│ │ │ ├── service
│ │ │ └── HelloService.java
│ │ │ └── web
│ │ │ └── HelloControler.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceRibbonApplicationTests.java
├── chapter3
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
├── service-feign
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ ├── ServiceFeignApplication.java
│ │ │ │ ├── service
│ │ │ │ └── SchedualServiceHi.java
│ │ │ │ └── web
│ │ │ │ └── HiController.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceFeignApplicationTests.java
├── service-hi-8763
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
├── service-hi
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
└── service-ribbon
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ ├── ServiceRibbonApplication.java
│ │ │ ├── service
│ │ │ └── HelloService.java
│ │ │ └── web
│ │ │ └── HelloControler.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceRibbonApplicationTests.java
├── chapter4
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
├── service-feign
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ ├── ServiceFeignApplication.java
│ │ │ │ ├── service
│ │ │ │ ├── SchedualServiceHi.java
│ │ │ │ └── SchedualServiceHiHystric.java
│ │ │ │ └── web
│ │ │ │ └── HiController.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceFeignApplicationTests.java
├── service-hi
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
└── service-ribbon
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ ├── ServiceRibbonApplication.java
│ │ │ ├── service
│ │ │ └── HelloService.java
│ │ │ └── web
│ │ │ └── HelloControler.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceRibbonApplicationTests.java
├── chapter5
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
├── pom.xml
├── service-feign
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ ├── ServiceFeignApplication.java
│ │ │ │ ├── service
│ │ │ │ ├── SchedualServiceHi.java
│ │ │ │ └── SchedualServiceHiHystric.java
│ │ │ │ └── web
│ │ │ │ └── HiController.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceFeignApplicationTests.java
├── service-hi
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ServiceHiApplication.java
│ │ └── resources
│ │ │ └── bootstrap.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceHiApplicationTests.java
├── service-ribbon
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ ├── ServiceRibbonApplication.java
│ │ │ │ ├── service
│ │ │ │ └── HelloService.java
│ │ │ │ └── web
│ │ │ │ └── HelloControler.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ServiceRibbonApplicationTests.java
└── service-zuul
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ ├── MyFilter.java
│ │ │ └── ServiceZuulApplication.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceZuulApplicationTests.java
├── chapter6
├── config-client
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigClientApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigClientApplicationTests.java
├── config-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigServerApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigServerApplicationTests.java
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
└── pom.xml
├── chapter7
├── config-client
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigClientApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigClientApplicationTests.java
├── config-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigServerApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigServerApplicationTests.java
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
└── pom.xml
├── chapter8
├── config-client-8882
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigClientApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigClientApplicationTests.java
├── config-client
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigClientApplication.java
│ │ └── resources
│ │ │ └── bootstrap.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigClientApplicationTests.java
├── config-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── ConfigServerApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── ConfigServerApplicationTests.java
├── eureka-server
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── forezp
│ │ │ │ └── EurekaServerApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── forezp
│ │ └── EurekaServerApplicationTests.java
└── pom.xml
└── chapter9
├── pom.xml
├── service-hi
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── forezp
│ │ │ └── ServiceHiApplication.java
│ └── resources
│ │ ├── application.properties
│ │ └── logback.xml
│ └── test
│ └── java
│ └── com
│ └── forezp
│ └── ServiceHiApplicationTests.java
└── service-miya
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── forezp
│ │ └── ServiceMiyaApplication.java
└── resources
│ ├── application.properties
│ └── logback.xml
└── test
└── java
└── com
└── forezp
└── ServiceMiyaApplicationTests.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpringCloud-Finchley-samples
2 | SpringCloud-Finchley 版本demo示例
3 |
4 | 最近Spring Cloud Finchley版本出来了,但是网上demo还是比较少,这篇CSDN博客:https://blog.csdn.net/forezp/article/details/70148833/ 比较火,所以就把代码版本给升级了下。
5 |
6 | 其实Cloud做了很多开发不需要做的事,把运维的很多事给做了。又由于为了抢占市场,做的太急了,所以可以看到各个版本有很多变动。新版本Bug还是蛮多的。大家如果要用还是需要慎重些!
7 |
8 |
9 | # 大家可以进我的群:492056222。一起讨论交流。
10 |
--------------------------------------------------------------------------------
/chapter1/eureka-server/.springBeans:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1
4 |
5 |
6 |
7 |
8 |
9 |
10 | java:com.jeegem.EurekaServerApplication
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/chapter1/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | junit
23 | junit
24 | test
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-netflix-eureka-server
30 |
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-dependencies
47 | Finchley.RC2
48 | pom
49 | import
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | spring-milestones
58 | Spring Milestones
59 | https://repo.spring.io/libs-milestone
60 |
61 | false
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.boot
70 | spring-boot-maven-plugin
71 |
72 |
73 | org.apache.maven.plugins
74 | maven-surefire-plugin
75 |
76 | true
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/chapter1/eureka-server/src/main/java/com/jeegem/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.jeegem;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter1/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
12 |
--------------------------------------------------------------------------------
/chapter1/eureka-server/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
7 |
8 |
9 |
11 |
12 |
13 | logs/logback/springboot_%d{yyyy-M-d}.log
14 |
15 | 10
16 |
17 |
18 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
19 |
20 |
21 |
23 |
24 | logs/logback/jeegem_%d{yyyy-M-d}.log
25 |
26 | 10
27 |
28 |
29 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
30 |
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/chapter1/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter1/service-hi/.springBeans:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1
4 |
5 |
6 |
7 |
8 |
9 |
10 | java:com.jeegem.ServiceHiApplication
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/chapter1/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | junit
30 | junit
31 | test
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-netflix-eureka-server
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-web
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-zipkin
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-starter-test
48 | test
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-dependencies
57 | Finchley.RC2
58 | pom
59 | import
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.boot
70 | spring-boot-maven-plugin
71 |
72 |
73 | org.apache.maven.plugins
74 | maven-surefire-plugin
75 |
76 | true
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | spring-milestones
85 | Spring Milestones
86 | https://repo.spring.io/milestone
87 |
88 | false
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/chapter1/service-hi/src/main/java/com/jeegem/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.jeegem;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter1/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8762
7 | spring:
8 | application:
9 | name: service-hi
10 | zipkin:
11 | base-url: http://192.168.0.105:9411/zipkin/
--------------------------------------------------------------------------------
/chapter1/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter10/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC1
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter10/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter10/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | serviceUrl:
9 | defaultZone: http://localhost:8761/eureka/
10 |
--------------------------------------------------------------------------------
/chapter10/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter10/eureka-server2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server2
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server2
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC1
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter10/eureka-server2/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter10/eureka-server2/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8762
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | serviceUrl:
9 | defaultZone: http://localhost:8761/eureka/
10 |
--------------------------------------------------------------------------------
/chapter10/eureka-server2/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter10/eureka-server3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server3
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server3
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC1
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter10/eureka-server3/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter10/eureka-server3/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8763
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | serviceUrl:
9 | defaultZone: http://localhost:8761/eureka/
10 |
--------------------------------------------------------------------------------
/chapter10/eureka-server3/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter10/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter10/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC1
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter10/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter10/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | # defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/,http://localhost:8763/eureka/
5 | defaultZone: http://localhost:8763/eureka/
6 | server:
7 | port: 8766
8 | spring:
9 | application:
10 | name: service-hi
--------------------------------------------------------------------------------
/chapter10/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter11-2/docker-compose-dev.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | eureka-server:
4 | build: eureka-server
5 | ports:
6 | - 8761:8761
7 |
8 | service-hi:
9 | build: service-hi
10 | ports:
11 | - 8763:8763
12 |
13 |
14 |
--------------------------------------------------------------------------------
/chapter11-2/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | eureka-server:
4 | image: forezp/eureka-server
5 | restart: always
6 | ports:
7 | - 8761:8761
8 |
9 | service-hi:
10 | image: forezp/service-hi
11 | restart: always
12 | ports:
13 | - 8763:8763
14 |
15 |
16 |
--------------------------------------------------------------------------------
/chapter11-2/eureka-server/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM frolvlad/alpine-oraclejdk8:slim
2 | VOLUME /tmp
3 | ADD ./target/eureka-server-0.0.1-SNAPSHOT.jar app.jar
4 | #RUN bash -c 'touch /app.jar'
5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
6 | EXPOSE 8761
--------------------------------------------------------------------------------
/chapter11-2/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter11-2/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 | eureka:
4 | instance:
5 | prefer-ip-address: true
6 | client:
7 | registerWithEureka: false
8 | fetchRegistry: false
9 |
--------------------------------------------------------------------------------
/chapter11-2/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter11-2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 | pom
11 |
12 | eureka-server
13 | service-hi
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/chapter11-2/service-hi/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM frolvlad/alpine-oraclejdk8:slim
2 | VOLUME /tmp
3 | ADD ./target/service-hi-0.0.1-SNAPSHOT.jar app.jar
4 | #RUN bash -c 'touch /app.jar'
5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
6 |
--------------------------------------------------------------------------------
/chapter11-2/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter11-2/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://eureka-server:8761/eureka/
5 | server:
6 | port: 8763
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter11-2/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter11/docker-compose-dev.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | eureka-server:
4 | build: eureka-server
5 | ports:
6 | - 8761:8761
7 |
8 | service-hi:
9 | build: service-hi
10 | ports:
11 | - 8763:8763
12 |
13 |
14 |
--------------------------------------------------------------------------------
/chapter11/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | eureka-server:
4 | image: forezp/eureka-server
5 | restart: always
6 | ports:
7 | - 8761:8761
8 |
9 | service-hi:
10 | image: forezp/service-hi
11 | restart: always
12 | ports:
13 | - 8763:8763
14 |
15 |
16 |
--------------------------------------------------------------------------------
/chapter11/eureka-server/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM frolvlad/alpine-oraclejdk8:slim
2 | VOLUME /tmp
3 | ADD eureka-server-0.0.1-SNAPSHOT.jar app.jar
4 | #RUN bash -c 'touch /app.jar'
5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
6 | EXPOSE 8761
--------------------------------------------------------------------------------
/chapter11/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter11/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 | eureka:
4 | instance:
5 | prefer-ip-address: true
6 | client:
7 | registerWithEureka: false
8 | fetchRegistry: false
9 |
--------------------------------------------------------------------------------
/chapter11/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter11/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 | pom
11 |
12 | eureka-server
13 | service-hi
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/chapter11/service-hi/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM frolvlad/alpine-oraclejdk8:slim
2 | VOLUME /tmp
3 | ADD service-hi-0.0.1-SNAPSHOT.jar app.jar
4 | #RUN bash -c 'touch /app.jar'
5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
6 |
--------------------------------------------------------------------------------
/chapter11/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter11/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://eureka-server:8761/eureka/
5 | server:
6 | port: 8763
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter11/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter12/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC2
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-maven-plugin
58 |
59 |
60 | org.apache.maven.plugins
61 | maven-surefire-plugin
62 |
63 | true
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/chapter12/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter12/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter12/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter12/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter12/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8 | import org.springframework.cloud.netflix.hystrix.EnableHystrix;
9 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestParam;
12 | import org.springframework.web.bind.annotation.RestController;
13 |
14 | @SpringBootApplication
15 | @EnableEurekaClient
16 | @RestController
17 | @EnableHystrix
18 | @EnableHystrixDashboard
19 | public class ServiceHiApplication {
20 |
21 | public static void main(String[] args) {
22 | SpringApplication.run(ServiceHiApplication.class, args);
23 | }
24 |
25 | @Value("${server.port}")
26 | String port;
27 | @RequestMapping("/hi")
28 | @HystrixCommand(fallbackMethod = "hiError")
29 | public String home(@RequestParam String name) {
30 | return "hi "+name+",i am from port:" +port;
31 | }
32 |
33 | public String hiError(String name) {
34 | return "hi,"+name+",sorry,error!";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/chapter12/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8092
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter12/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter13/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC2
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
63 | spring-milestones
64 | Spring Milestones
65 | https://repo.spring.io/milestone
66 |
67 | false
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/chapter13/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter13/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter13/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter13/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter13/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-actuator
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-netflix-hystrix-dashboard
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-starter-netflix-hystrix
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-dependencies
62 | Finchley.RC2
63 | pom
64 | import
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-maven-plugin
74 |
75 |
76 |
77 |
78 |
79 |
80 | spring-milestones
81 | Spring Milestones
82 | https://repo.spring.io/milestone
83 |
84 | false
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/chapter13/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8 | import org.springframework.cloud.netflix.hystrix.EnableHystrix;
9 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestParam;
12 | import org.springframework.web.bind.annotation.RestController;
13 |
14 | @SpringBootApplication
15 | @EnableEurekaClient
16 | @RestController
17 | @EnableHystrix
18 | @EnableHystrixDashboard
19 | public class ServiceHiApplication {
20 |
21 | public static void main(String[] args) {
22 | SpringApplication.run(ServiceHiApplication.class, args);
23 | }
24 |
25 | @Value("${server.port}")
26 | String port;
27 | @RequestMapping("/hi")
28 | @HystrixCommand(fallbackMethod = "hiError")
29 | public String home(@RequestParam String name) {
30 | return "hi "+name+",i am from port:" +port;
31 | }
32 |
33 | public String hiError(String name) {
34 | return "hi,"+name+",sorry,error!";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/chapter13/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8762
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter13/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter13/service-lucy/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-lucy
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-lucy
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-starter-actuator
46 |
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-starter-netflix-hystrix-dashboard
51 |
52 |
53 | org.springframework.cloud
54 | spring-cloud-starter-netflix-hystrix
55 |
56 |
57 |
58 |
59 |
60 |
61 | org.springframework.cloud
62 | spring-cloud-dependencies
63 | Finchley.RC2
64 | pom
65 | import
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.springframework.boot
74 | spring-boot-maven-plugin
75 |
76 |
77 |
78 |
79 |
80 |
81 | spring-milestones
82 | Spring Milestones
83 | https://repo.spring.io/milestone
84 |
85 | false
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/chapter13/service-lucy/src/main/java/com/forezp/ServiceLucyApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8 | import org.springframework.cloud.netflix.hystrix.EnableHystrix;
9 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestParam;
12 | import org.springframework.web.bind.annotation.RestController;
13 |
14 | @SpringBootApplication
15 | @EnableEurekaClient
16 | @RestController
17 | @EnableHystrix
18 | @EnableHystrixDashboard
19 | public class ServiceLucyApplication {
20 |
21 | public static void main(String[] args) {
22 | SpringApplication.run(ServiceLucyApplication.class, args);
23 | }
24 |
25 | @Value("${server.port}")
26 | String port;
27 | @RequestMapping("/hi")
28 | @HystrixCommand(fallbackMethod = "hiError")
29 | public String home(@RequestParam String name) {
30 | return "hi "+name+",i am lucy and from port:" +port;
31 | }
32 |
33 | public String hiError(String name) {
34 | return "hi,"+name+",sorry,error!";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/chapter13/service-lucy/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8763
7 | spring:
8 | application:
9 | name: service-lucy
--------------------------------------------------------------------------------
/chapter13/service-lucy/src/test/java/com/forezp/ServiceLucyApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceLucyApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter13/service-turbine/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-turbine
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-turbine
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-turbine
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-netflix-turbine
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-actuator
39 |
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-test
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | Finchley.RC1
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 |
68 |
69 |
70 |
71 | spring-milestones
72 | Spring Milestones
73 | https://repo.spring.io/milestone
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/chapter13/service-turbine/src/main/java/com/forezp/ServiceTurbineApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 |
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.builder.SpringApplicationBuilder;
6 | import org.springframework.cloud.netflix.turbine.EnableTurbine;
7 |
8 | @SpringBootApplication
9 | @EnableTurbine
10 |
11 | public class ServiceTurbineApplication {
12 |
13 | public static void main(String[] args) {
14 |
15 | new SpringApplicationBuilder(ServiceTurbineApplication.class).run(args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/chapter13/service-turbine/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application.name: service-turbine
3 | server:
4 | port: 8769
5 | #security.basic.enabled: false
6 |
7 | turbine:
8 | aggregator:
9 | clusterConfig: default # 指定聚合哪些集群,多个使用","分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问
10 | appConfig: service-hi,service-lucy ### 配置Eureka中的serviceId列表,表明监控哪些服务
11 | clusterNameExpression: new String("default")
12 | # 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称
13 | # 2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default
14 | # 3. 当clusterNameExpression: metadata['cluster']时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC
15 | eureka:
16 | client:
17 | serviceUrl:
18 | defaultZone: http://localhost:8761/eureka/
19 |
20 |
21 |
--------------------------------------------------------------------------------
/chapter13/service-turbine/src/test/java/com/forezp/ServiceTurbineApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceTurbineApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter14/consul-miya/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | consul-miya
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | consul-miya
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-consul-discovery
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 | org.springframework.cloud
55 | spring-cloud-consul-dependencies
56 | 2.0.0.RC2
57 | pom
58 | import
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | org.springframework.boot
67 | spring-boot-maven-plugin
68 |
69 |
70 | org.apache.maven.plugins
71 | maven-surefire-plugin
72 |
73 | true
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | spring-milestones
82 | Spring Milestones
83 | https://repo.spring.io/milestone
84 |
85 | false
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/chapter14/consul-miya/src/main/java/com/forezp/ConsulMiyaApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 |
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.builder.SpringApplicationBuilder;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @SpringBootApplication
11 | @EnableDiscoveryClient
12 | @RestController
13 | public class ConsulMiyaApplication {
14 |
15 | @RequestMapping("/hi")
16 | public String home() {
17 | return "hi ,i'm miya";
18 | }
19 |
20 | public static void main(String[] args) {
21 | new SpringApplicationBuilder(ConsulMiyaApplication.class).web(true).run(args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/chapter14/consul-miya/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | consul:
4 | host: localhost
5 | port: 8500
6 | discovery:
7 | instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
8 | application:
9 | name: consul-miya
10 | server:
11 | port: 8502
12 |
13 |
--------------------------------------------------------------------------------
/chapter14/consul-miya/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
7 |
8 |
9 |
11 |
12 |
13 | logs/logback/springboot_%d{yyyy-M-d}.log
14 |
15 | 10
16 |
17 |
18 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
19 |
20 |
21 |
23 |
24 | logs/logback/jeegem_%d{yyyy-M-d}.log
25 |
26 | 10
27 |
28 |
29 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
30 |
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/chapter14/consul-miya/src/test/java/com/forezp/ConsulMiyaApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConsulMiyaApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter14/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter14
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter2/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 |
30 | junit
31 | junit
32 | test
33 |
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-netflix-eureka-server
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-test
43 | test
44 |
45 |
46 |
47 |
48 |
49 |
50 | org.springframework.cloud
51 | spring-cloud-dependencies
52 | Finchley.RC2
53 | pom
54 | import
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-maven-plugin
64 |
65 |
66 | org.apache.maven.plugins
67 | maven-surefire-plugin
68 |
69 | true
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | spring-milestones
78 | Spring Milestones
79 | https://repo.spring.io/milestone
80 |
81 | false
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/chapter2/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter2/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter2/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter2/service-hi-8762/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi-8762
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi-8762
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter2/service-hi-8762/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter2/service-hi-8762/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8762
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter2/service-hi-8762/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter2/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter2/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter2/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8763
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter2/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter2/service-ribbon/src/main/java/com/forezp/ServiceRibbonApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.web.client.RestTemplate;
9 |
10 | @SpringBootApplication
11 | @EnableDiscoveryClient
12 | public class ServiceRibbonApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ServiceRibbonApplication.class, args);
16 | }
17 |
18 | @Bean
19 | @LoadBalanced
20 | RestTemplate restTemplate() {
21 | return new RestTemplate();
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/chapter2/service-ribbon/src/main/java/com/forezp/service/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 |
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | /**
9 | * Created by fangzhipeng on 2017/4/6.
10 | */
11 | @Service
12 | public class HelloService {
13 |
14 | @Autowired
15 | RestTemplate restTemplate;
16 |
17 | public String hiService(String name) {
18 | return restTemplate.getForObject("http://SERVICE-HI/hi?name="+name,String.class);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/chapter2/service-ribbon/src/main/java/com/forezp/web/HelloControler.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.HelloService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | /**
10 | * Created by fangzhipeng on 2017/4/6.
11 | */
12 | @RestController
13 | public class HelloControler {
14 |
15 |
16 |
17 | @Autowired
18 | HelloService helloService;
19 |
20 | @RequestMapping(value = "/hi")
21 | public String hi(@RequestParam String name){
22 | return helloService.hiService(name);
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/chapter2/service-ribbon/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8764
7 | spring:
8 | application:
9 | name: service-ribbon
--------------------------------------------------------------------------------
/chapter2/service-ribbon/src/test/java/com/forezp/ServiceRibbonApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceRibbonApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter3/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC2
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter3/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter3/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter3/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter3/service-feign/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-feign
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-feign
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-openfeign
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-web
39 |
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-test
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | Finchley.RC2
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-surefire-plugin
69 |
70 | true
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | spring-milestones
79 | Spring Milestones
80 | https://repo.spring.io/milestone
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/chapter3/service-feign/src/main/java/com/forezp/ServiceFeignApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.openfeign.EnableFeignClients;
7 |
8 | @SpringBootApplication
9 | @EnableDiscoveryClient
10 | @EnableFeignClients
11 | public class ServiceFeignApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ServiceFeignApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/chapter3/service-feign/src/main/java/com/forezp/service/SchedualServiceHi.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 | import org.springframework.cloud.openfeign.FeignClient;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RequestMethod;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * Created by fangzhipeng on 2017/4/6.
10 | */
11 | @FeignClient(value = "service-hi")
12 | public interface SchedualServiceHi {
13 | @RequestMapping(value = "/hi",method = RequestMethod.GET)
14 | String sayHiFromClientOne(@RequestParam(value = "name") String name);
15 | }
16 |
--------------------------------------------------------------------------------
/chapter3/service-feign/src/main/java/com/forezp/web/HiController.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.SchedualServiceHi;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestMethod;
7 | import org.springframework.web.bind.annotation.RequestParam;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | /**
11 | * Created by fangzhipeng on 2017/4/6.
12 | */
13 | @RestController
14 | public class HiController {
15 |
16 | @Autowired
17 | SchedualServiceHi schedualServiceHi;
18 | @RequestMapping(value = "/hi",method = RequestMethod.GET)
19 | public String sayHi(@RequestParam String name){
20 | return schedualServiceHi.sayHiFromClientOne(name);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter3/service-feign/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8765
7 | spring:
8 | application:
9 | name: service-feign
--------------------------------------------------------------------------------
/chapter3/service-feign/src/test/java/com/forezp/ServiceFeignApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceFeignApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter3/service-hi-8763/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi-8763
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi-8763
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter3/service-hi-8763/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter3/service-hi-8763/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8763
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter3/service-hi-8763/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter3/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter3/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter3/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8762
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter3/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter3/service-ribbon/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-ribbon
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-ribbon
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-netflix-ribbon
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-web
39 |
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-test
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | Finchley.RC2
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-surefire-plugin
69 |
70 | true
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | spring-milestones
79 | Spring Milestones
80 | https://repo.spring.io/milestone
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/chapter3/service-ribbon/src/main/java/com/forezp/ServiceRibbonApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.web.client.RestTemplate;
9 |
10 | @SpringBootApplication
11 | @EnableDiscoveryClient
12 | public class ServiceRibbonApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ServiceRibbonApplication.class, args);
16 | }
17 |
18 | @Bean
19 | @LoadBalanced
20 | RestTemplate restTemplate() {
21 | return new RestTemplate();
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/chapter3/service-ribbon/src/main/java/com/forezp/service/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 |
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | /**
9 | * Created by fangzhipeng on 2017/4/6.
10 | */
11 | @Service
12 | public class HelloService {
13 |
14 | @Autowired
15 | RestTemplate restTemplate;
16 |
17 | public String hiService(String name) {
18 | return restTemplate.getForObject("http://SERVICE-HI/hi?name="+name,String.class);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/chapter3/service-ribbon/src/main/java/com/forezp/web/HelloControler.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.HelloService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | /**
10 | * Created by fangzhipeng on 2017/4/6.
11 | */
12 | @RestController
13 | public class HelloControler {
14 |
15 | @Autowired
16 | HelloService helloService;
17 | @RequestMapping(value = "/hi")
18 | public String hi(@RequestParam String name){
19 | return helloService.hiService(name);
20 | }
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/chapter3/service-ribbon/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8764
7 | spring:
8 | application:
9 | name: service-ribbon
--------------------------------------------------------------------------------
/chapter3/service-ribbon/src/test/java/com/forezp/ServiceRibbonApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceRibbonApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter4/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC2
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter4/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter4/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter4/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter4/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter4/service-feign/src/main/java/com/forezp/ServiceFeignApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.openfeign.EnableFeignClients;
7 |
8 | @SpringBootApplication
9 | @EnableDiscoveryClient
10 | @EnableFeignClients
11 | public class ServiceFeignApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ServiceFeignApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/chapter4/service-feign/src/main/java/com/forezp/service/SchedualServiceHi.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 | import org.springframework.cloud.openfeign.FeignClient;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RequestMethod;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * Created by fangzhipeng on 2017/4/6.
10 | */
11 | @FeignClient(value = "service-hi",fallback = SchedualServiceHiHystric.class)
12 | public interface SchedualServiceHi {
13 | @RequestMapping(value = "/hi",method = RequestMethod.GET)
14 | String sayHiFromClientOne(@RequestParam(value = "name") String name);
15 | }
16 |
--------------------------------------------------------------------------------
/chapter4/service-feign/src/main/java/com/forezp/service/SchedualServiceHiHystric.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | /**
6 | * Created by fangzhipeng on 2017/4/6.
7 | */
8 | @Component
9 | public class SchedualServiceHiHystric implements SchedualServiceHi {
10 | @Override
11 | public String sayHiFromClientOne(String name) {
12 | return "sorry "+name;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter4/service-feign/src/main/java/com/forezp/web/HiController.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.SchedualServiceHi;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestMethod;
7 | import org.springframework.web.bind.annotation.RequestParam;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | /**
11 | * Created by fangzhipeng on 2017/4/6.
12 | */
13 | @RestController
14 | public class HiController {
15 |
16 | @Autowired
17 | SchedualServiceHi schedualServiceHi;
18 | @RequestMapping(value = "/hi",method = RequestMethod.GET)
19 | public String sayHi(@RequestParam String name){
20 | return schedualServiceHi.sayHiFromClientOne(name);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter4/service-feign/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8765
7 | spring:
8 | application:
9 | name: service-feign
10 | feign:
11 | hystrix:
12 | enabled: true
13 |
--------------------------------------------------------------------------------
/chapter4/service-feign/src/test/java/com/forezp/ServiceFeignApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceFeignApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter4/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter4/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter4/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8762
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter4/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter4/service-ribbon/src/main/java/com/forezp/ServiceRibbonApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.web.servlet.ServletRegistrationBean;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
8 | import org.springframework.cloud.netflix.hystrix.EnableHystrix;
9 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
10 | import org.springframework.context.annotation.Bean;
11 | import org.springframework.web.client.RestTemplate;
12 |
13 | import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
14 |
15 | @SpringBootApplication
16 | @EnableDiscoveryClient
17 | @EnableHystrix
18 | @EnableHystrixDashboard
19 | public class ServiceRibbonApplication {
20 |
21 | public static void main(String[] args) {
22 | SpringApplication.run(ServiceRibbonApplication.class, args);
23 | }
24 |
25 | @Bean
26 | @LoadBalanced
27 | RestTemplate restTemplate() {
28 | return new RestTemplate();
29 | }
30 |
31 | @Bean
32 | public ServletRegistrationBean getServlet() {
33 | HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
34 | ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
35 | registrationBean.setLoadOnStartup(1);
36 | registrationBean.addUrlMappings("/hystrix.stream");
37 | registrationBean.setName("HystrixMetricsStreamServlet");
38 | return registrationBean;
39 |
40 | }
41 | }
--------------------------------------------------------------------------------
/chapter4/service-ribbon/src/main/java/com/forezp/service/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 |
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
9 |
10 | /**
11 | * Created by fangzhipeng on 2017/4/6.
12 | */
13 | @Service
14 | public class HelloService {
15 |
16 | @Autowired
17 | RestTemplate restTemplate;
18 |
19 | @HystrixCommand(fallbackMethod = "hiError")
20 | public String hiService(String name) {
21 | return restTemplate.getForObject("http://SERVICE-HI/hi?name="+name,String.class);
22 | }
23 |
24 | public String hiError(String name) {
25 | return "hi,"+name+",sorry,error!";
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/chapter4/service-ribbon/src/main/java/com/forezp/web/HelloControler.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.HelloService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | /**
10 | * Created by fangzhipeng on 2017/4/6.
11 | */
12 | @RestController
13 | public class HelloControler {
14 | @Autowired
15 | HelloService helloService;
16 | @RequestMapping(value = "/hi")
17 | public String hi(@RequestParam String name){
18 | return helloService.hiService(name);
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/chapter4/service-ribbon/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8764
7 | spring:
8 | application:
9 | name: service-ribbon
10 | management:
11 | endpoints:
12 | web:
13 | exposure:
14 | include: hystrix.stream
15 |
--------------------------------------------------------------------------------
/chapter4/service-ribbon/src/test/java/com/forezp/ServiceRibbonApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceRibbonApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter5/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC2
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter5/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter5/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter5/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter5/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter1
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter5/service-feign/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-feign
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-feign
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-openfeign
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-web
39 |
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-test
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | Finchley.RC2
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-surefire-plugin
69 |
70 | true
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | spring-milestones
79 | Spring Milestones
80 | https://repo.spring.io/milestone
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/chapter5/service-feign/src/main/java/com/forezp/ServiceFeignApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.openfeign.EnableFeignClients;
7 |
8 | @SpringBootApplication
9 | @EnableDiscoveryClient
10 | @EnableFeignClients
11 | public class ServiceFeignApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ServiceFeignApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/chapter5/service-feign/src/main/java/com/forezp/service/SchedualServiceHi.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 | import org.springframework.cloud.openfeign.FeignClient;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RequestMethod;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * Created by fangzhipeng on 2017/4/6.
10 | */
11 | @FeignClient(value = "service-hi",fallback = SchedualServiceHiHystric.class)
12 | public interface SchedualServiceHi {
13 | @RequestMapping(value = "/hi",method = RequestMethod.GET)
14 | String sayHiFromClientOne(@RequestParam(value = "name") String name);
15 | }
16 |
--------------------------------------------------------------------------------
/chapter5/service-feign/src/main/java/com/forezp/service/SchedualServiceHiHystric.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | /**
6 | * Created by fangzhipeng on 2017/4/6.
7 | */
8 | @Component
9 | public class SchedualServiceHiHystric implements SchedualServiceHi {
10 | @Override
11 | public String sayHiFromClientOne(String name) {
12 | return "sorry "+name;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter5/service-feign/src/main/java/com/forezp/web/HiController.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.SchedualServiceHi;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestMethod;
7 | import org.springframework.web.bind.annotation.RequestParam;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | /**
11 | * Created by fangzhipeng on 2017/4/6.
12 | */
13 | @RestController
14 | public class HiController {
15 |
16 | @Autowired
17 | SchedualServiceHi schedualServiceHi;
18 | @RequestMapping(value = "/hi",method = RequestMethod.GET)
19 | public String sayHi(@RequestParam String name){
20 | return schedualServiceHi.sayHiFromClientOne(name);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter5/service-feign/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8765
7 | spring:
8 | application:
9 | name: service-feign
--------------------------------------------------------------------------------
/chapter5/service-feign/src/test/java/com/forezp/ServiceFeignApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceFeignApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter5/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-surefire-plugin
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter5/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | public class ServiceHiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(ServiceHiApplication.class, args);
18 | }
19 |
20 | @Value("${server.port}")
21 | String port;
22 | @RequestMapping("/hi")
23 | public String home(@RequestParam String name) {
24 | return "hi "+name+",i am from port:" +port;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/chapter5/service-hi/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8762
7 | spring:
8 | application:
9 | name: service-hi
--------------------------------------------------------------------------------
/chapter5/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter5/service-ribbon/src/main/java/com/forezp/ServiceRibbonApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
7 | import org.springframework.cloud.netflix.hystrix.EnableHystrix;
8 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.web.client.RestTemplate;
11 |
12 | @SpringBootApplication
13 | @EnableDiscoveryClient
14 | @EnableHystrix
15 | @EnableHystrixDashboard
16 | public class ServiceRibbonApplication {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(ServiceRibbonApplication.class, args);
20 | }
21 |
22 | @Bean
23 | @LoadBalanced
24 | RestTemplate restTemplate() {
25 | return new RestTemplate();
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/chapter5/service-ribbon/src/main/java/com/forezp/service/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.forezp.service;
2 |
3 |
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
9 |
10 | /**
11 | * Created by fangzhipeng on 2017/4/6.
12 | */
13 | @Service
14 | public class HelloService {
15 |
16 | @Autowired
17 | RestTemplate restTemplate;
18 |
19 | @HystrixCommand(fallbackMethod = "hiError")
20 | public String hiService(String name) {
21 | return restTemplate.getForObject("http://SERVICE-HI/hi?name="+name,String.class);
22 | }
23 |
24 | public String hiError(String name) {
25 | return "hi,"+name+",sorry,error!";
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/chapter5/service-ribbon/src/main/java/com/forezp/web/HelloControler.java:
--------------------------------------------------------------------------------
1 | package com.forezp.web;
2 |
3 | import com.forezp.service.HelloService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | /**
10 | * Created by fangzhipeng on 2017/4/6.
11 | */
12 | @RestController
13 | public class HelloControler {
14 | @Autowired
15 | HelloService helloService;
16 | @RequestMapping(value = "/hi")
17 | public String hi(@RequestParam String name){
18 | return helloService.hiService(name);
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/chapter5/service-ribbon/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8764
7 | spring:
8 | application:
9 | name: service-ribbon
--------------------------------------------------------------------------------
/chapter5/service-ribbon/src/test/java/com/forezp/ServiceRibbonApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceRibbonApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter5/service-zuul/src/main/java/com/forezp/MyFilter.java:
--------------------------------------------------------------------------------
1 | //package com.forezp;
2 | //
3 | //import javax.servlet.http.HttpServletRequest;
4 | //
5 | //import org.slf4j.Logger;
6 | //import org.slf4j.LoggerFactory;
7 | //import org.springframework.stereotype.Component;
8 | //
9 | //import com.netflix.zuul.ZuulFilter;
10 | //import com.netflix.zuul.context.RequestContext;
11 | ///**
12 | // * Created by forezp on 2017/4/8.
13 | // */
14 | //@Component
15 | //public class MyFilter extends ZuulFilter{
16 | //
17 | // private static Logger log = LoggerFactory.getLogger(MyFilter.class);
18 | // @Override
19 | // public String filterType() {
20 | // return "pre";
21 | // }
22 | //
23 | // @Override
24 | // public int filterOrder() {
25 | // return 0;
26 | // }
27 | //
28 | // @Override
29 | // public boolean shouldFilter() {
30 | // return true;
31 | // }
32 | //
33 | // @Override
34 | // public Object run() {
35 | // RequestContext ctx = RequestContext.getCurrentContext();
36 | // HttpServletRequest request = ctx.getRequest();
37 | // log.info(String.format("%s >>> %s", request.getMethod(), request.getRequestURL().toString()));
38 | // Object accessToken = request.getParameter("token");
39 | // if(accessToken == null) {
40 | // log.warn("token is empty");
41 | // ctx.setSendZuulResponse(false);
42 | // ctx.setResponseStatusCode(401);
43 | // try {
44 | // ctx.getResponse().getWriter().write("token is empty");
45 | // }catch (Exception e){}
46 | //
47 | // return null;
48 | // }
49 | // log.info("ok");
50 | // return null;
51 | // }
52 | //}
53 |
--------------------------------------------------------------------------------
/chapter5/service-zuul/src/main/java/com/forezp/ServiceZuulApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
7 |
8 | @EnableZuulProxy
9 | @EnableEurekaClient
10 | @SpringBootApplication
11 | public class ServiceZuulApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ServiceZuulApplication.class, args);
15 | }
16 |
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/chapter5/service-zuul/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | client:
3 | serviceUrl:
4 | defaultZone: http://localhost:8761/eureka/
5 | server:
6 | port: 8769
7 | spring:
8 | application:
9 | name: service-zuul
10 | zuul:
11 | routes:
12 | api-a:
13 | path: /api-a/**
14 | serviceId: service-ribbon
15 | api-b:
16 | path: /api-b/**
17 | serviceId: service-feign
--------------------------------------------------------------------------------
/chapter5/service-zuul/src/test/java/com/forezp/ServiceZuulApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceZuulApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter6/config-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | config-client
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-client
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-config
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-web
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-starter-test
41 | test
42 |
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-devtools
48 | true
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-dependencies
58 | Finchley.RC2
59 | pom
60 | import
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | org.springframework.boot
69 | spring-boot-maven-plugin
70 |
71 |
72 | org.apache.maven.plugins
73 | maven-surefire-plugin
74 |
75 | true
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | spring-milestones
84 | Spring Milestones
85 | https://repo.spring.io/milestone
86 |
87 | false
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/chapter6/config-client/src/main/java/com/forezp/ConfigClientApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | @SpringBootApplication
10 | @RestController
11 | public class ConfigClientApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ConfigClientApplication.class, args);
15 | }
16 |
17 | @Value("${foo}")
18 | String foo;
19 | @RequestMapping(value = "/hi")
20 | public String hi(){
21 | return foo;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/chapter6/config-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-client
2 | spring.cloud.config.label=master
3 | spring.cloud.config.profile=dev
4 | spring.cloud.config.uri= http://localhost:8888/
5 | server.port=8881
6 |
7 |
--------------------------------------------------------------------------------
/chapter6/config-client/src/test/java/com/forezp/ConfigClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter6/config-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | config-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-config-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-devtools
43 | true
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-starter-netflix-eureka-server
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-dependencies
57 | Finchley.RC1
58 | pom
59 | import
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | org.springframework.boot
69 | spring-boot-maven-plugin
70 |
71 |
72 | org.apache.maven.plugins
73 | maven-surefire-plugin
74 |
75 | true
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | spring-milestones
84 | Spring Milestones
85 | https://repo.spring.io/milestone
86 |
87 | false
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/chapter6/config-server/src/main/java/com/forezp/ConfigServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 |
8 | @SpringBootApplication
9 | @EnableConfigServer
10 | public class ConfigServerApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(ConfigServerApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/chapter6/config-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-server
2 | server.port=8888
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
5 | spring.cloud.config.server.git.uri=https://gitee.com/JeeGemEdu/SpringCloudConfig
6 | #spring.cloud.config.server.git.uri=https://github.com/forezp/SpringcloudConfig/
7 | spring.cloud.config.server.git.searchPaths=respo
8 | #spring.cloud.config.label=master
9 | spring.cloud.config.server.git.username=
10 | spring.cloud.config.server.git.password=
11 |
12 |
--------------------------------------------------------------------------------
/chapter6/config-server/src/test/java/com/forezp/ConfigServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter6/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | Finchley.RC2
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-surefire-plugin
61 |
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/milestone
73 |
74 | false
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/chapter6/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter6/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter6/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter6/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter6
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter7/config-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | config-client
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-client
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-config
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-web
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-netflix-eureka-server
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 |
49 |
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-dependencies
54 | Finchley.RC2
55 | pom
56 | import
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.boot
65 | spring-boot-maven-plugin
66 |
67 |
68 | org.apache.maven.plugins
69 | maven-surefire-plugin
70 |
71 | true
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | spring-milestones
80 | Spring Milestones
81 | https://repo.spring.io/milestone
82 |
83 | false
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/chapter7/config-client/src/main/java/com/forezp/ConfigClientApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.context.config.annotation.RefreshScope;
7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | @RefreshScope
15 | public class ConfigClientApplication {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(ConfigClientApplication.class, args);
19 | }
20 |
21 | @Value("${foo}")
22 | String foo;
23 |
24 | @RequestMapping(value = "/hi")
25 | public String hi(){
26 | return foo;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/chapter7/config-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-client
2 | spring.cloud.config.label=master
3 | spring.cloud.config.profile=dev
4 | #spring.cloud.config.uri= http://localhost:8888/
5 |
6 | eureka.client.serviceUrl.defaultZone=http://localhost:8889/eureka/
7 | spring.cloud.config.discovery.enabled=true
8 | spring.cloud.config.discovery.serviceId=config-server
9 | server.port=8881
10 |
11 |
--------------------------------------------------------------------------------
/chapter7/config-client/src/test/java/com/forezp/ConfigClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter7/config-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | config-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-config-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-netflix-eureka-server
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-dependencies
50 | Finchley.RC1
51 | pom
52 | import
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-maven-plugin
63 |
64 |
65 | org.apache.maven.plugins
66 | maven-surefire-plugin
67 |
68 | true
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | spring-milestones
77 | Spring Milestones
78 | https://repo.spring.io/milestone
79 |
80 | false
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/chapter7/config-server/src/main/java/com/forezp/ConfigServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 |
8 |
9 | @SpringBootApplication
10 | @EnableConfigServer
11 | @EnableEurekaClient
12 | public class ConfigServerApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ConfigServerApplication.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/chapter7/config-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-server
2 | server.port=8888
3 |
4 | #spring.cloud.config.server.git.uri=https://github.com/forezp/SpringcloudConfig/
5 | spring.cloud.config.server.git.uri=https://gitee.com/JeeGemEdu/SpringCloudConfig
6 | spring.cloud.config.server.git.searchPaths=respo
7 | spring.cloud.config.label=master
8 | spring.cloud.config.server.git.username=
9 | spring.cloud.config.server.git.password=
10 | eureka.client.serviceUrl.defaultZone=http://localhost:8889/eureka/
--------------------------------------------------------------------------------
/chapter7/config-server/src/test/java/com/forezp/ConfigServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter7/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC2
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 |
64 |
65 |
66 |
67 | spring-milestones
68 | Spring Milestones
69 | https://repo.spring.io/milestone
70 |
71 | false
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/chapter7/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter7/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8889
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter7/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter7/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter7
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter8/config-client-8882/src/main/java/com/forezp/ConfigClientApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.context.config.annotation.RefreshScope;
7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | @RefreshScope
15 | public class ConfigClientApplication {
16 |
17 | @Value("${foo}")
18 | String foo;
19 | public static void main(String[] args) {
20 | SpringApplication.run(ConfigClientApplication.class, args);
21 | }
22 |
23 |
24 | @RequestMapping(value = "/hi")
25 | public String hi(){
26 | return foo;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/chapter8/config-client-8882/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-client
2 | spring.cloud.config.label=master
3 | spring.cloud.config.profile=dev
4 | #spring.cloud.config.uri= http://localhost:8888/
5 |
6 | server.port=8882
7 | eureka.client.serviceUrl.defaultZone=http://localhost:8889/eureka/
8 | spring.cloud.config.discovery.enabled=true
9 | spring.cloud.config.discovery.serviceId=config-server
10 |
11 | spring.rabbitmq.host=localhost
12 | spring.rabbitmq.port=5672
13 | spring.rabbitmq.username=jeegem
14 | spring.rabbitmq.password=jeegem
15 |
16 |
--------------------------------------------------------------------------------
/chapter8/config-client-8882/src/test/java/com/forezp/ConfigClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter8/config-client/src/main/java/com/forezp/ConfigClientApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.context.config.annotation.RefreshScope;
7 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | @EnableEurekaClient
13 | @RestController
14 | @RefreshScope
15 | public class ConfigClientApplication {
16 |
17 | @Value("${foo}")
18 | String foo;
19 | public static void main(String[] args) {
20 | SpringApplication.run(ConfigClientApplication.class, args);
21 | }
22 |
23 |
24 | @RequestMapping(value = "/hi")
25 | public String hi(){
26 | return foo;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/chapter8/config-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-client
2 | spring.cloud.config.label=master
3 | spring.cloud.config.profile=dev
4 | #spring.cloud.config.uri= http://localhost:8888/
5 |
6 | server.port=8881
7 | eureka.client.serviceUrl.defaultZone=http://localhost:8889/eureka/
8 | spring.cloud.config.discovery.enabled=true
9 | spring.cloud.config.discovery.serviceId=config-server
10 | management.security.enabled=false
11 |
12 | spring.rabbitmq.host=localhost
13 | spring.rabbitmq.port=5672
14 | spring.rabbitmq.username=jeegem
15 | spring.rabbitmq.password=jeegem
16 |
17 |
--------------------------------------------------------------------------------
/chapter8/config-client/src/test/java/com/forezp/ConfigClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter8/config-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | config-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | config-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-config-server
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-netflix-eureka-server
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-starter-bus-amqp
47 |
48 |
49 |
50 |
51 |
52 |
53 | org.springframework.cloud
54 | spring-cloud-dependencies
55 | Finchley.RC1
56 | pom
57 | import
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | org.springframework.boot
67 | spring-boot-maven-plugin
68 |
69 |
70 |
71 |
72 |
73 |
74 | spring-milestones
75 | Spring Milestones
76 | https://repo.spring.io/milestone
77 |
78 | false
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/chapter8/config-server/src/main/java/com/forezp/ConfigServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.config.server.EnableConfigServer;
7 |
8 |
9 | @SpringBootApplication
10 | @EnableConfigServer
11 | @EnableDiscoveryClient
12 | public class ConfigServerApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ConfigServerApplication.class, args);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/chapter8/config-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-server
2 | server.port=8888
3 |
4 |
5 | #spring.cloud.config.server.git.uri=https://github.com/forezp/SpringcloudConfig/
6 | spring.cloud.config.server.git.uri=https://gitee.com/JeeGemEdu/SpringCloudConfig
7 | spring.cloud.config.server.git.searchPaths=respo
8 | spring.cloud.config.label=master
9 | spring.cloud.config.server.git.username=
10 | spring.cloud.config.server.git.password=
11 |
12 | eureka.client.serviceUrl.defaultZone=http://localhost:8889/eureka/
--------------------------------------------------------------------------------
/chapter8/config-server/src/test/java/com/forezp/ConfigServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ConfigServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter8/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | eureka-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | eureka-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-netflix-eureka-server
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Finchley.RC1
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 |
64 |
65 |
66 |
67 | spring-milestones
68 | Spring Milestones
69 | https://repo.spring.io/milestone
70 |
71 | false
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/chapter8/eureka-server/src/main/java/com/forezp/EurekaServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class EurekaServerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(EurekaServerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter8/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8889
3 |
4 | eureka:
5 | instance:
6 | hostname: localhost
7 | client:
8 | registerWithEureka: false
9 | fetchRegistry: false
10 | serviceUrl:
11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
--------------------------------------------------------------------------------
/chapter8/eureka-server/src/test/java/com/forezp/EurekaServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class EurekaServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter8/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter7
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter9/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.forezp
8 | chapter9
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter9/service-hi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-hi
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-hi
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-web
32 |
33 |
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-zipkin
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-test
43 | test
44 |
45 |
46 |
47 |
48 |
49 |
50 | org.springframework.cloud
51 | spring-cloud-dependencies
52 | Finchley.RC2
53 | pom
54 | import
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-maven-plugin
64 |
65 |
66 | org.apache.maven.plugins
67 | maven-surefire-plugin
68 |
69 | true
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | spring-milestones
78 | Spring Milestones
79 | https://repo.spring.io/milestone
80 |
81 | false
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/chapter9/service-hi/src/main/java/com/forezp/ServiceHiApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import java.util.logging.Level;
4 | import java.util.logging.Logger;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.SpringApplication;
8 | import org.springframework.boot.autoconfigure.SpringBootApplication;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RestController;
12 | import org.springframework.web.client.RestTemplate;
13 |
14 | import brave.sampler.Sampler;
15 |
16 | @SpringBootApplication
17 | @RestController
18 | public class ServiceHiApplication {
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(ServiceHiApplication.class, args);
22 | }
23 |
24 | private static final Logger LOG = Logger.getLogger(ServiceHiApplication.class.getName());
25 |
26 |
27 | @Autowired
28 | private RestTemplate restTemplate;
29 |
30 | @Bean
31 | public RestTemplate getRestTemplate(){
32 | return new RestTemplate();
33 | }
34 |
35 | @RequestMapping("/hi")
36 | public String callHome(){
37 | LOG.log(Level.INFO, "calling trace service-hi ");
38 | return restTemplate.getForObject("http://localhost:8989/miya", String.class);
39 | }
40 |
41 | @RequestMapping("/info")
42 | public String info(){
43 | LOG.log(Level.INFO, "calling trace service-hi ");
44 |
45 | return "i'm service-hi";
46 |
47 | }
48 |
49 | @Bean
50 | public Sampler defaultSampler(){
51 | return Sampler.ALWAYS_SAMPLE;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/chapter9/service-hi/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8988
2 | spring.zipkin.base-url=http://192.168.0.105:9411
3 | spring.application.name=service-hi
--------------------------------------------------------------------------------
/chapter9/service-hi/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
7 |
8 |
9 |
11 |
12 |
13 | logs/logback/springboot_%d{yyyy-M-d}.log
14 |
15 | 10
16 |
17 |
18 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
19 |
20 |
21 |
23 |
24 | logs/logback/jeegem_%d{yyyy-M-d}.log
25 |
26 | 10
27 |
28 |
29 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
30 |
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/chapter9/service-hi/src/test/java/com/forezp/ServiceHiApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceHiApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/chapter9/service-miya/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.forezp
7 | service-miya
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | service-miya
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-starter-zipkin
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-test
42 | test
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | Finchley.RC2
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-surefire-plugin
69 |
70 | true
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | spring-milestones
79 | Spring Milestones
80 | https://repo.spring.io/milestone
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/chapter9/service-miya/src/main/java/com/forezp/ServiceMiyaApplication.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | import java.util.logging.Level;
12 | import java.util.logging.Logger;
13 |
14 | @SpringBootApplication
15 | @RestController
16 | public class ServiceMiyaApplication {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(ServiceMiyaApplication.class, args);
20 | }
21 |
22 | private static final Logger LOG = Logger.getLogger(ServiceMiyaApplication.class.getName());
23 |
24 |
25 | @RequestMapping("/hi")
26 | public String home(){
27 | LOG.log(Level.INFO, "hi is being called");
28 | return "hi i'm miya!";
29 | }
30 |
31 | @RequestMapping("/miya")
32 | public String info(){
33 | LOG.log(Level.INFO, "info is being called");
34 | return restTemplate.getForObject("http://localhost:8988/info",String.class);
35 | }
36 |
37 | @Autowired
38 | private RestTemplate restTemplate;
39 |
40 | @Bean
41 | public RestTemplate getRestTemplate(){
42 | return new RestTemplate();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/chapter9/service-miya/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8989
2 | spring.zipkin.base-url=http://192.168.0.105:9411
3 | spring.application.name=service-miya
--------------------------------------------------------------------------------
/chapter9/service-miya/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
7 |
8 |
9 |
11 |
12 |
13 | logs/logback/springboot_%d{yyyy-M-d}.log
14 |
15 | 10
16 |
17 |
18 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
19 |
20 |
21 |
23 |
24 | logs/logback/jeegem_%d{yyyy-M-d}.log
25 |
26 | 10
27 |
28 |
29 | %d{yyyy-M-d HH:mm:ss} %t %p %m%n
30 |
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/chapter9/service-miya/src/test/java/com/forezp/ServiceMiyaApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.forezp;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ServiceMiyaApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------