springcloud微服务学习笔记9:支付微服务8001入驻eurekaServer
springcloud微服务学习笔记目录:
springcloud微服务学习笔记
1.修改pom文件
在支付微服务8001中的pom文件加入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
2.修改yml文件
在yml文件添加
spring:
application:
name: cloud-payment-service
eureka:
client:
#表示是否将自己注册进eurekaServer 默认为true
register-with-eureka: true
#是否从eurekaServer抓取已有的注册信息,默认为true,单节点无所谓,集群必须设置为true才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://localhost:7001/eureka

3.修改主启动类
在主启动类中加入注解
@EnableEurekaClient
4.测试
先启动eurekaServer
地址:http://localhost:7001


注意报这个错,为yml文件中格式错误,检查缩进和空格


浙公网安备 33010602011771号