请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

在我的项目中引入nacos,启动后出现链接地址为localhost:8848错误,我配置的是172.16.22.33:8848

pom文件如下(关键的位置):

org.springframework.boot
spring-boot-starter-parent
2.3.2.RELEASE





com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-config



com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery




com.alibaba.cloud
spring-cloud-alibaba-dependencies
2.2.5.RELEASE
pom
import



配置文件:
spring.application.name=shell
#spring.cloud.nacos.config.server-addr=172.16.22.33:8848
#spring.cloud.nacos.config.file-extension=properties
spring.cloud.nacos.discovery.service=shell
spring.cloud.nacos.discovery.server-addr=172.16.22.33:8848
项目启动报错:
[2021-05-15 18:06:25,225] [ERROR] [com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:109)] - [NACOS ConnectException httpGet] currentServerAddr:http://localhost:8848, err : Connection refused (Connection refused)
[2021-05-15 18:06:25,420] [ERROR] [com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:109)] - [NACOS ConnectException httpGet] currentServerAddr:http://localhost:8848, err : Connection refused (Connection refused)
[2021-05-15 18:06:25,618] [ERROR] [com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:109)] - [NACOS ConnectException httpGet] currentServerAddr:http://localhost:8848, err : Connection refused (Connection refused)
[2021-05-15 18:06:25,822] [ERROR] [com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:109)] - [NACOS ConnectException httpGet] currentServerAddr:http://localhost:8848, err : Connection refused (Connection refused)
[2021-05-15 18:06:25,823] [ERROR] [com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:279)] - [fixed-localhost_8848] [sub-server] get server config exception, dataId=shell, group=DEFAULT_GROUP, tenant=
java.net.ConnectException: [NACOS HTTP-GET] The maximum number of tolerable server reconnection errors has been reached

正在回答 回答被采纳积分+3

3回答

子牙老师 2021-08-30 22:29:40

关于启动文件读取顺序的问题属于springboot课程的范畴。老师也在config课程当中进行了简单的讲解。图文教程中有的

0 回复 有任何疑惑可以回复我~
提问者 qq_慕盖茨649478 2021-05-17 12:06:11

nacos的配置必须配置在,bootstrap. properties

因为服务配置与服务发现的包引用的是starter
,这个的自动配置优先级会在application. properties高,然而bootstrap. properties的优先级比starter还高

所以配置在bootstrap.properties的nacos信息可以生效,子牙老师在课上也讲到过配置在bootstrap上,少说了为什么配置在这里

0 回复 有任何疑惑可以回复我~
提问者 qq_慕盖茨649478 2021-05-16 13:10:29

解决了。。。。

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信