The spring cloudAlibaba gateway reported an error, indicating that it could not find the registration center to register itself.
1. Error message
2020-12-29 11:10:18.521 WARN 232 --- [freshExecutor-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: java.net.ConnectException: Connection refused: connect
2020-12-29 11:10:18.521 ERROR 232 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CLOUD-GATEWAY/tyeerth:cloud-gateway:9527 - 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
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[eureka-client-1.9.13.jar:1.9.13]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.9.13.jar:1.9.13]
a
2. In the startup class
@SpringBootApplication(exclude= {
DataSourceAutoConfiguration.class})
@EnableEurekaClient
- Using this annotation, the client will automatically search for the Eureka Server. If it cannot find it, it will report this error. But we are using the nacos registration center, so an error is reported.
3. Solve
-
Just disable the automatic search for the registration center.
-
eureka: client: register-with-eureka: false fetch-registry: false
-
Here we use nacos registration center
cloud: nacos: discovery: server-addr: localhost:8848 #配置Nacos地址,注册到nacos注册中心