具体报错信息:
18:40:24.282 [com.alibaba.nacos.client.Worker.longPolling.fixed-localhost_8848] ERROR c.a.n.c.c.h.ServerHttpAgent - [httpPost,166] - [NACOS ConnectException httpPost] currentServerAddr: http://localhost:8848, err : Connection refused: connect
18:40:25.127 [SpringContextShutdownHook] INFO c.a.n.client.naming - [shutdown,132] - com.alibaba.nacos.client.naming.core.PushReceiver do shutdown begin
18:40:26.325 [com.alibaba.nacos.client.Worker.longPolling.fixed-localhost_8848] ERROR c.a.n.c.c.h.ServerHttpAgent - [httpPost,166] - [NACOS ConnectException httpPost] currentServerAddr: http://localhost:8848, err : Connection refused: connect
分析原因:
连接 nacos 错误的连接到了 localhost,这和配置想要的大相径庭,可以确定一定是少了配置(因为一般没有配置成本地的情况下,localhost都是找不到对应配置的参数,然后采用了默认的配置)
其次连接nacos无非就是两个目的:服务,配置(注册、订阅服务,获取nacos共享配置)
服务的已经通过 spring.cloud.nacos.discovery 配置了,那么就是少了配置文件的了,加上 spring.cloud.nacos.config 然后就是地址,命名空间一搞 ,然后ok了
最终解决:
添加了config的发现地址和命名空间
拓展:
bootstrap.yml 会比 application.yml 提前执行