Eureka客户端启动报错(was unable to refresh its cache status=Cannot execute request on any known server)

问题描述:

在正常启动Eureka服务端后,想要去连接Eureka客户端,但是客户端在启动时报错。

如图:

was unable to refresh its cache! status = Cannot execute request on any known server

由于Eureka服务端的正常开启,我认为问题应该不是出在springboot和springcloud的依赖版本上。

应该是配置文件出现了问题

原因分析:

在解决问题前,yaml配置文件如下:

1、Eureka服务端

server:
  port: 7001
  servlet:
    context-path: /eureka

#Eureka配置
eureka:
  instance:
    hostname: localhost # Eureka服务端实例的名字
  client:
    register-with-eureka: false # 表示是否向Eureka注册中心注册自己
    fetch-registry: false #如果为false,则表示自己为注册中心
    service-url: # 监控页面地址,也就是到时候需要进入的地址
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

2、Eureka客户端

server:
  port: 8001

#mybatis配置
mybatis:
  type-aliases-package: com.lch.springcloud.pojo
  config-location: classpath:mybatis/mybatis-config.xml
  mapper-locations: classpath:mybatis/mapper/*.xml

#spring配置
spring:
  application:
    name: springcloud-provider-dept
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/db01?useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=UTC
    type: com.alibaba.druid.pool.DruidDataSource

#Eureka的配置,服务注册到哪里
eureka:
  instance:
    hostname: localhost
  client:
    service-url:
      defaultZone: http://localhost:7001/eureka/

在网上找到的内容都是说Eureka服务端没有配置拒绝向配置中心配置自己和表示自己为注册中心,但是我修改后依然出错。

解决:

修改Eureka客户端yaml配置文件

客户端的访问注册中心的路径出错,要在路径上加上/eureka/eureka/ 第二个/eureka/是表示在注册中心根目录下的测试

server:
  port: 8001

#mybatis配置
mybatis:
  type-aliases-package: com.lch.springcloud.pojo
  config-location: classpath:mybatis/mybatis-config.xml
  mapper-locations: classpath:mybatis/mapper/*.xml

#spring配置
spring:
  application:
    name: springcloud-provider-dept
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/db01?useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=UTC
    type: com.alibaba.druid.pool.DruidDataSource

#Eureka的配置,服务注册到哪里
eureka:
  instance:
    hostname: localhost
  client:
    service-url:
      defaultZone: http://localhost:7001/eureka/eureka/

 测试:

成功 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值