当前位置: 代码迷 >> 综合 >> 启动报错com.sun.jersey.api.client.ClientHandlerException: Cannot execute request on any known server
  详细解决方案

启动报错com.sun.jersey.api.client.ClientHandlerException: Cannot execute request on any known server

热度:92   发布时间:2024-02-28 01:38:48.0

详细报错信息:
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
at …
at …org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at com.itheima.security.distributed.uaa.UAAServer.main(UAAServer.java:20) ~[classes/:na]
Caused by: java.net.ConnectException: Connection refused: connect

2020-10-13 17:32:49.019 WARN 24436 — [ main] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: java.net.ConnectException: Connection refused: connect
2020-10-13 17:32:49.020 ERROR 24436 — [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_UAA-SERVICE/= uaa-service:192.168.50.158:53020 - was unable to refresh its cache! status = Cannot execute request on any known server

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

解决办法:配置下面两行:

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false
即:

spring.datasource.url = jdbc:mysql://localhost:3306/oauth2?useUnicode=true&&characterEncoding=UTF-8&useSSL=false
spring.datasource.username = root
spring.datasource.password = 123456
spring.datasource.driver-class-name = com.mysql.jdbc.Drivereureka.client.serviceUrl.defaultZone = http://localhost:5300/eureka/
#因为eureka默认是为true,所以会一直不停的报错,需要修改eureka配置信息 下面两行:
# 禁止自己当做服务注册
eureka.client.register-with-eureka=false
#屏蔽注册信息
eureka.client.fetch-registry=false
eureka.instance.preferIpAddress = true
eureka.instance.instance-id= = ${
    spring.application.name}:${
    spring.cloud.client.ip-address}:${
    spring.application.instance_id:${
    server.port}}
management.endpoints.web.exposure.include = refresh,health,info,env
  相关解决方案