From 8931aab2264d577f302bba407b28e5c160db887a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Thu, 2 Jun 2016 13:07:17 +0800 Subject: [PATCH] =?UTF-8?q?Spring=20Cloud=E6=9E=84=E5=BB=BA=E5=BE=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=9E=B6=E6=9E=84=EF=BC=88=E4=B8=80=EF=BC=89?= =?UTF-8?q?=E2=80=94=E2=80=94=E6=9C=8D=E5=8A=A1=E6=B3=A8=E5=86=8C=E4=B8=8E?= =?UTF-8?q?=E5=8F=91=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Chapter9-1-1/eureka-client/pom.xml | 73 ------------------- .../java/com/didispace/ClientApplication.java | 23 ------ .../com/didispace/service/ComputeService.java | 19 ----- .../com/didispace/web/ClientController.java | 30 -------- .../src/main/resources/application.yml | 14 ---- .../java/com/didispace/ApplicationTests.java | 25 ------- 6 files changed, 184 deletions(-) delete mode 100644 Chapter9-1-1/eureka-client/pom.xml delete mode 100755 Chapter9-1-1/eureka-client/src/main/java/com/didispace/ClientApplication.java delete mode 100644 Chapter9-1-1/eureka-client/src/main/java/com/didispace/service/ComputeService.java delete mode 100755 Chapter9-1-1/eureka-client/src/main/java/com/didispace/web/ClientController.java delete mode 100755 Chapter9-1-1/eureka-client/src/main/resources/application.yml delete mode 100755 Chapter9-1-1/eureka-client/src/test/java/com/didispace/ApplicationTests.java diff --git a/Chapter9-1-1/eureka-client/pom.xml b/Chapter9-1-1/eureka-client/pom.xml deleted file mode 100644 index a52cebf..0000000 --- a/Chapter9-1-1/eureka-client/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - - com.didispace - eureka-client - 1.0.0 - jar - - eureka-client - Spring Cloud project - - - org.springframework.cloud - spring-cloud-starter-parent - 1.0.0.RELEASE - - - - UTF-8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.cloud - spring-cloud-starter - - - - org.springframework.cloud - spring-cloud-starter-eureka - - - - org.springframework.cloud - spring-cloud-starter-ribbon - - - - org.springframework.cloud - spring-cloud-starter-feign - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - \ No newline at end of file diff --git a/Chapter9-1-1/eureka-client/src/main/java/com/didispace/ClientApplication.java b/Chapter9-1-1/eureka-client/src/main/java/com/didispace/ClientApplication.java deleted file mode 100755 index 990445a..0000000 --- a/Chapter9-1-1/eureka-client/src/main/java/com/didispace/ClientApplication.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.didispace; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.context.annotation.Bean; -import org.springframework.web.client.RestTemplate; - -@SpringBootApplication -@EnableEurekaClient -public class ClientApplication { - - @Bean - RestTemplate restTemplate() { - return new RestTemplate(); - } - - public static void main(String[] args) { - SpringApplication.run(ClientApplication.class, args); - } - -} diff --git a/Chapter9-1-1/eureka-client/src/main/java/com/didispace/service/ComputeService.java b/Chapter9-1-1/eureka-client/src/main/java/com/didispace/service/ComputeService.java deleted file mode 100644 index 7a78246..0000000 --- a/Chapter9-1-1/eureka-client/src/main/java/com/didispace/service/ComputeService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.didispace.service; - -import feign.Param; -import feign.RequestLine; -import org.springframework.cloud.netflix.feign.FeignClient; - -/** - * @author 程序猿DD - * @version 1.0.0 - * @date 16/5/30 下午3:48. - * @blog http://blog.didispace.com - */ -@FeignClient(serviceId = "computeService", url = "http://COMPUTE-SERVICE/") -public interface ComputeService { - - @RequestLine("GET /add") - Integer add(@Param("a") Integer a, @Param("b") Integer b); - -} diff --git a/Chapter9-1-1/eureka-client/src/main/java/com/didispace/web/ClientController.java b/Chapter9-1-1/eureka-client/src/main/java/com/didispace/web/ClientController.java deleted file mode 100755 index 2e03f7c..0000000 --- a/Chapter9-1-1/eureka-client/src/main/java/com/didispace/web/ClientController.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.didispace.web; - -import com.didispace.service.ComputeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; - -@RestController -public class ClientController { - - @Autowired - RestTemplate restTemplate; - -// @Autowired -// private ComputeService computeService; - - @RequestMapping(value = "/add", method = RequestMethod.GET) - public String add() { - return restTemplate.getForEntity("http://COMPUTE-SERVICE/add?a=10&b=20", String.class).getBody(); - } - -// @RequestMapping("/add2") -// public String add2() { -// return computeService.add(10, 20).toString(); -// } - - -} \ No newline at end of file diff --git a/Chapter9-1-1/eureka-client/src/main/resources/application.yml b/Chapter9-1-1/eureka-client/src/main/resources/application.yml deleted file mode 100755 index a361e8a..0000000 --- a/Chapter9-1-1/eureka-client/src/main/resources/application.yml +++ /dev/null @@ -1,14 +0,0 @@ -# Spring Properties -spring: - application: - name: client - -# Discovery Server Access -eureka: - client: - serviceUrl: - defaultZone: http://localhost:1111/eureka/ - -# HTTP Server -server: - port: 3333 # HTTP (Tomcat) port \ No newline at end of file diff --git a/Chapter9-1-1/eureka-client/src/test/java/com/didispace/ApplicationTests.java b/Chapter9-1-1/eureka-client/src/test/java/com/didispace/ApplicationTests.java deleted file mode 100755 index d5735ec..0000000 --- a/Chapter9-1-1/eureka-client/src/test/java/com/didispace/ApplicationTests.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.didispace; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.client.RestTemplate; - - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = ClientApplication.class) -public class ApplicationTests { - - @Autowired - RestTemplate restTemplate; - - @Test - public void compute() throws Exception { - - System.out.println(restTemplate.getForEntity("http://COMPUTE-SERVICE/add?a=10&b=20", String.class).getBody()); - - } - -}