码上敲享录 > springcloud开发经验分享 > eureka注册报错Cannot execute request on any known server

eureka注册报错Cannot execute request on any known server

上一章章节目录下一章 2018-04-12已有4035人阅读 评论(0)

springcloud的应用向eureka注册中心注册失败,报错如下:com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

解决方法:

先确定注册中心是否已经启动,如果注册中心已启动,并可以访问,那就注意再要注册的应用中添加下面红色的代码。

1.注册中心配置

server:

 port: 18081                    # 指定该Eureka实例的端口
eureka:
 instance:
   hostname: localhost         # 指定该Eureka实例的主机名
client:
   registerWithEureka: false
   fetchRegistry: false

   serviceUrl:
     defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

2.要注册的应用配置

application:

 name: all-in-one    # 项目名称尽量用小写

eureka:

   client:

        register-with-eureka: true

        fetch-registry: true

        serviceUrl:

          defaultZone: http://localhost:18081/eureka/    # 指定注册中心的地址

    instance:

       preferIpAddress: true

ribbon:

 eureka:

   enabled: false


本文地址:http://www.yayihouse.com/yayishuwu/chapter/1173

0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交