Problem description
Spring cloud Alibaba micro service architecture is used, and Nacos is used in the service discovery and configuration center
At the beginning, Nacos was started locally, and everything was normal,
After Nacos is migrated to the cloud, change the Nacos address in the configuration file
The gateway service reports an error java.net.connectexception: no available server
, because it is always connected to localhost:8848
.
The console outputs the following screenshot:
Cause location
Because the parent POM dependency is imported:
spring-cloud-starter-Alibaba-Nacos-config
and spring-cloud-starter-Alibaba-Nacos-discovery
In local development, items such as testing, registration and discovery are configured in application.yml
, the central configuration file bootstrap.properties
is not created
Springboot automation configuration defaults to localhost:8848
, so there is no problem with the local environment.
Solution:
Remove useless dependencies (if nacos-config is not used, remove spring-cloud-starter-alibaba-nacos-config dependencies)