1、导入坐标
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
2、启动类注解启用eureka-client
@SpringBootApplication
@EnableEurekaClient //启用eurekaclient,新版本可以省略
public class ProviderApp {
public static void main(String[] args) {
SpringApplication.run(ProviderApp.class,args);
}
}
3、编写配置文件
server:
port: 8000
eureka:
instance:
hostname: localhost
client:
service-url:
defaultZone: http://localhost:8761/eureka #与之通信的eureka服务端地址
spring:
application:
name: eureka-provider #设置当前应用名称,在eureka中Aoolication显示,通过该名称可以获取路径