搭建Eureka客户端
1.idea创建Eureka客户端项目
File->new->project->spring initializer->select dependencies Eureka Discovery Client->下一步 创建
2.application.yml
###服务启动端口号
server:
port: 8002
###服务名称(服务注册到eureka名称)
spring:
application:
name: app-itmayiedu-order
###服务注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:8000/eureka
###因为该应用为注册中心,不会注册自己
register-with-eureka: true
###是否需要从eureka上获取注册信息
fetch-registry: true
3.启动Eureka客户端
@SpringBootApplication
@EnableEurekaClient
public class AppOrder {
public static void main(String[] args) {
SpringApplication.run(AppOrder.class,args);
}
}
#@EnableEurekaClient开启Eureka客户端
4.查看是否启动成功