0%

SpringCloud Eureka-client

pom.xml

1
2
3
4
5
6
7
8
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

application.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
server:
port: 7002

eureka:
instance:
hostname: localhost
client:
serviceUrl:
defaultZone: http://localhost:7001/eureka/ #注册中心的地址

spring:
application:
name: eureka-client #服务的名字

启动类加上注解**@EnableEurekaClient**