Spring Cloud探路(二) Erueka客户端的建立

接上篇

1、pom.xml与上篇一致
2、新建包及Application启动类
  1. @Configuration
  2. @ComponentScan
  3. @EnableEurekaClient
  4. @EnableAutoConfiguration
  5. @RestController
  6. public class Application {
  7. @RequestMapping(value = "hello",method = RequestMethod.GET)
  8. public String hello(){
  9. return "你好,世界";
  10. }
  11. public static void main(String[] args){
  12. new SpringApplicationBuilder(Application.class).web(true)
  13. .run(args);
  14. }
  15. }
3、新建application.yml配置文件(我们尝试两种不同的配置)
  1. eureka:
  2. client:
  3. serviceUrl:
  4. defaultZone: http://localhost:1000/eureka/
  1. eureka:
  2. client:
  3. serviceUrl:
  4. defaultZone: http://localhost:1000/eureka/
  5. spring:
  6. application:
  7. name: client-service1
  8. server:
  9. port: 2000
4、运行,查看之前Erueka服务端的页面
 

 




posted @ 2017-03-16 17:22  二刀  阅读(1303)  评论(0编辑  收藏  举报