Example of using spring cloud: eureka feign
Assumes Project (from ZaSpringCloud) is running on http://localhost:8761
mvn package
run java -jar ZaEurekaServer/target/za-eureka-server-0.0.1-SNAPSHOT.jar
verify it is functioning at http://localhost:8761
You should see Spring Eureka Console
run java -jar za-eureka-client/target/za-eureka-client-0.0.1-SNAPSHOT.jar
verify it is functioning at http://localhost:8763/hi?name=latti
You should see hi hello,i am from port:8763 and 29
If you want to run multiple service provider just like following:
java -jar provider-0.0.1-SNAPSHOT.jar --server.port=8762
java -jar provider-0.0.1-SNAPSHOT.jar --server.port=8763
Verify it is functioning at http://localhost:8765/hi?name=latti
You should see hi latti,i am from port:8763 and 36
You may see an error while the eureka/ribbon caches warm up similar to the following:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jan 07 13:13:39 MST 2015
There was an unexpected error (type=Internal Server Error, status=500).
com.netflix.client.ClientException: Load balancer does not have available server for client: HelloServer
It should go away shortly.
Verify it is functioning at http://localhost:8771/ribbon-consumer
You should see like:
hi ribbon,i am from port:8762 and 7
or
hi ribbon,i am from port:8763 and 35
http://localhost:8771/sayHi http://localhost:8771/sayHi2 http://localhost:8771/sayHi3 http://localhost:8771/book1
打开浏览器访问:http://localhost:8781/api-a/hi?name=latti ;
浏览器显示:
hi latti,i am from port:8762 and 164(Ribbon+RestTemplate)
打开浏览器访问:http://localhost:8781/api-b/hi?name=latti ;
浏览器显示:
hi latti,i am from port:8762 and 162 (FEIGN)
Add Filer then visit: http://localhost:8781/api-b/hi?name=lattimore
token is empty
{"name":"foo","profiles":["dev"],"label":null,"version":"00d32612a38898781bce791a4a845e60a7fbdb4e","state":null,"propertySources":[]}
foo version 2
Refer to: https://github.com/devbhuwan/eureka-client-with-springmvc https://stackoverflow.com/questions/35409492/eureka-service-discovery-without-spring-boot
Refer to README.md under project folder.