Nacos作为配置中心读取文件的异常[小坑]

    技术2022-07-10  79

    参考官网

    dataId配置方式:

    具体操作:

    去nacos后台,新建一个配置

    配置dataId

    远程配置名就是: nacos-config-client-dev.yaml

    我的controller如下图 按理来说应该能读到远程配置文件的config.info中的信息返回给网页 但是服务器启动出错了!!!!

    如果出现错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘scopedTarget.nacosConfigController’: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder ‘config.info’ in value "${config.info}"

    说明没有读取到配置

    1.看看是不是yaml配置成yml了。

    2.看看配置文件是不是和你配置的对不上。

    3.看看远程配置文件是不是这个属性。

    4.我这里就是第四种,搞了一两个小时

    查看日志发现

    The web application [ROOT] appears to have started a thread named [com.alibaba.nacos .naming.client.listener] but has failed to stop it…

    然后栈溢出。。。死循环。。。

    我找了半天没找出我的问题,以为是文件问题,然后气急败坏的重启了Nacos,结果好了。。。

    看看大家是不是上述问题。。不行的话重启下Nacos看看说不定就发生奇迹了!

    Processed: 0.010, SQL: 9