SpringCloud:Eureka Client项目搭建(Gradle项目)

test

gradle配置:

// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: '1.4.6.RELEASE'

  

EurekaclientApplication.java
 1 @SpringBootApplication
 2 @EnableEurekaClient
 3 @RestController
 4 public class EurekaclientApplication {
 5 
 6     public static void main(String[] args) {
 7         SpringApplication.run(EurekaclientApplication.class, args);
 8     }
 9 
10     @Value("${server.port}")
11     String port;
12     @RequestMapping("/")
13     public String home() {
14         return "hello world from port " + port;
15     }
16 
17 }

 

application.yml:

eureka:
    client:
        serviceUrl:
            defaultZone: http://localhost:8761/eureka/
server:
    port: 8762
spring:
    application:
        name: service-helloworld

  

注意要先启动Eureka Server.

 

posted @ 2019-01-08 20:56  临兵斗者  阅读(244)  评论(0)    收藏  举报