From d22909658f074271de2d74cf9b0c16fdb0fecae2 Mon Sep 17 00:00:00 2001 From: Xiangbin Han Date: Thu, 2 Aug 2018 16:21:43 +0800 Subject: [PATCH 1/2] Upgrade to Spring Boot 2.0.3.RELEASE and to Spring Cloud Finchley.RELEASE. --- client/pom.xml | 4 ++-- .../src/main/java/demo/HelloClientApplication.java | 4 ++-- pom.xml | 4 ++-- server/pom.xml | 4 ++-- .../src/main/java/demo/HelloServerApplication.java | 13 +++++++++++-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index bf82281..fb9bbf5 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -34,11 +34,11 @@ org.springframework.cloud - spring-cloud-starter-feign + spring-cloud-starter-openfeign org.springframework.cloud - spring-cloud-starter-eureka + spring-cloud-starter-netflix-eureka-client org.springframework.boot diff --git a/client/src/main/java/demo/HelloClientApplication.java b/client/src/main/java/demo/HelloClientApplication.java index 1131de6..82f305e 100644 --- a/client/src/main/java/demo/HelloClientApplication.java +++ b/client/src/main/java/demo/HelloClientApplication.java @@ -4,8 +4,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/pom.xml b/pom.xml index 55e0f38..6a70194 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.4.2.RELEASE + 2.0.3.RELEASE @@ -33,7 +33,7 @@ org.springframework.cloud spring-cloud-dependencies - Camden.BUILD-SNAPSHOT + Finchley.RELEASE pom import diff --git a/server/pom.xml b/server/pom.xml index 0502fa7..696c425 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -34,11 +34,11 @@ org.springframework.cloud - spring-cloud-starter-feign + spring-cloud-starter-openfeign org.springframework.cloud - spring-cloud-starter-eureka + spring-cloud-starter-netflix-eureka-client org.springframework.boot diff --git a/server/src/main/java/demo/HelloServerApplication.java b/server/src/main/java/demo/HelloServerApplication.java index 08d09fa..0929b46 100644 --- a/server/src/main/java/demo/HelloServerApplication.java +++ b/server/src/main/java/demo/HelloServerApplication.java @@ -1,5 +1,7 @@ package demo; +import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -21,8 +23,15 @@ public class HelloServerApplication { @RequestMapping("/") public String hello() { - ServiceInstance localInstance = client.getLocalServiceInstance(); - return "Hello World: "+ localInstance.getServiceId()+":"+localInstance.getHost()+":"+localInstance.getPort(); + StringBuilder result = new StringBuilder("Hello World: "); + List services = client.getServices(); + for(String serviceId: services) { + List localInstances = client.getInstances(serviceId); + for(ServiceInstance instance: localInstances) { + result.append(instance.getServiceId()+":"+instance.getHost()+":"+instance.getPort()); + } + } + return result.toString(); } public static void main(String[] args) { From 7eda19d5f19353b9bf605a4f8592e2f5ae66035c Mon Sep 17 00:00:00 2001 From: Xiangbin Han Date: Fri, 3 Aug 2018 15:33:42 +0800 Subject: [PATCH 2/2] Upgrade to SpringBoot 2.0.4.RELEASE and SpringCloud Finchley.SR1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6a70194..e62f73d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.3.RELEASE + 2.0.4.RELEASE @@ -33,7 +33,7 @@ org.springframework.cloud spring-cloud-dependencies - Finchley.RELEASE + Finchley.SR1 pom import