原因:
是因为eureka默认会去检索服务,当我们只写了这么一个注册中心(eureka)而没有其他服务的时候,它去检索服务就会出现上述错误。所以需要添加配置 fetch-registry: false。
修改后的代码:
server:
port: 10086
spring:
application:
name: eureka #将来作为微服务名称注入到eureka容器
eureka:
client:
service-url:
defaultZone: http://localhost:${server.port}/eureka/
register-with-eureka: false #false表示不向注册中心注册自己。
fetch-registry: false # false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务