日志如下,项目中配置的nacos地址都是远程地址,服务启动时提示 localhost:8848 connect time out.
2021-08-07 21:02:20.855 ERROR 10468 --- [ main] c.a.n.c.config.http.ServerHttpAgent : [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
2021-08-07 21:02:21.857 ERROR 10468 --- [ main] c.a.n.c.config.http.ServerHttpAgent : [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
2021-08-07 21:02:22.858 ERROR 10468 --- [ main] c.a.n.c.config.http.ServerHttpAgent : [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
2021-08-07 21:02:22.858 ERROR 10468 --- [ main] c.a.n.c.config.http.ServerHttpAgent : no available server
2021-08-07 21:02:22.860 ERROR 10468 --- [ main] c.a.n.client.config.impl.ClientWorker : [fixed-localhost_8848] [sub-server] get server config exception, dataId=gateway-service, group=DEFAULT_GROUP, tenant=
java.net.ConnectException: no available server
at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:133) ~[nacos-client-1.3.3.jar:na]
at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpGet(MetricsHttpAgent.java:51) ~[nacos-client-1.3.3.jar:na]
at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:298) ~[nacos-client-1.3.3.jar:na]
at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:149) [nacos-client-1.3.3.jar:na]
at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:97) [nacos-client-1.3.3.jar:na]
...
从日志看是 nacos的配置中心报的错,但是项目中配置的服务发现的地址,查看pom文件,发现pom中引入的是common的包。
common包含了配置中心和服务注册与发现的服务,对于仅需要discovery的工程需要将配置中心的jar包排除
<exclusions>
<exclusion>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</exclusion>
</exclusions>
网友评论