日志如下示惊,項目中配置的nacos地址都是遠(yuǎn)程地址,服務(wù)啟動時提示 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的配置中心報的錯相满,但是項目中配置的服務(wù)發(fā)現(xiàn)的地址层亿,查看pom文件,發(fā)現(xiàn)pom中引入的是common的包立美。
common包含了配置中心和服務(wù)注冊與發(fā)現(xiàn)的服務(wù)匿又,對于僅需要discovery的工程需要將配置中心的jar包排除
<exclusions>
<exclusion>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</exclusion>
</exclusions>