alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.07k stars 12.81k forks source link

修改prefix和file-extension无效,项目依然按${spring.application.name}.properties的dataid从nacos读取 #7795

Closed gyxbuaa closed 5 months ago

gyxbuaa commented 2 years ago

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

Nacos运行在windows系统中,1.4.2和2.0.3都试过了

我在application.yml如下配置: spring: application: name: order-service cloud: nacos: config: file-extension: yaml prefix: guo server-addr: 127.0.0.1.8848

那我在nacos中创建guo.yaml的dataid配置文件即可进行读取,但是项目只能读取order-service.properties的dataid配置文件

这是项目控制台的信息:[fixed-localhost_8848] [add-listener] ok, tenant=, dataId=order-service.properties, group=DEFAULT_GROUP, cnt=1

Describe what you expected to happen

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

nacos1.4.2&2.0.3 windows11 springboot 2.3.2.RELEASE springcloud Hoxton.SR9 springcloud Alibaba 2.2.6.RELEASE

Anything else we need to know?

SteafanMrZhou commented 2 years ago

简单跟进了下,初步判断可能是参数解析时出现了异常。@ i will resolve it.

gyxbuaa commented 2 years ago

请问您那边是复现了吗

SteafanMrZhou commented 2 years ago

请问您那边是复现了吗

是的

gyxbuaa commented 2 years ago

请问您那边是复现了吗

是的

这个好像是整个nacos的配置读取都失效了,我刚刚配置server-addr为云服务器也无效,默认按localhost:8848注册

SteafanMrZhou commented 2 years ago

请问您那边是复现了吗

是的

这个好像是整个nacos的配置读取都失效了,我刚刚配置server-addr为云服务器也无效,默认按localhost:8848注册

后续我详细跟进一下,看看有什么问题,然后会在这issue进行回复。

gyxbuaa commented 2 years ago

请问您那边是复现了吗

是的

这个好像是整个nacos的配置读取都失效了,我刚刚配置server-addr为云服务器也无效,默认按localhost:8848注册

后续我详细跟进一下,看看有什么问题,然后会在这issue进行回复。

好的,谢谢

as3324 commented 2 years ago

server.port=8082 spring.application.name=nacos-consumer spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 management.endpoints.web.exposure.include=*

自定义数据id

spring.cloud.nacos.config.ext-config.data-id=nacos-consumer-local.yaml

自定义组

spring.cloud.nacos.config.ext-config.group=DEFAULT_GROUP

使用yaml拓展名的配置文件

spring.cloud.nacos.config.file-extension=yaml

禁用Spring Cloud Nacos Config自动配置

spring.cloud.nacos.config.enabled=false 这是我的配置,也同样存在nacos-consumer-local.yaml这个配置文件不生效,而nacos-consumer-local.properties就生效.

以上配置是由于配置在application.properties里面,所以导致无效,后来改为了bootstrap.properties才生效,这是我对springboot的bootstrap配置和application配置不了解造成的原因

pkaq commented 2 years ago

我也是同样的问题 而且端点查看配置已经被读取了 只不过破坏了yaml的结构 是逐行读取

as3324 commented 2 years ago

我也是同样的问题 而且端点查看配置已经被读取了 只不过破坏了yaml的结构 是逐行读取

你的配置是放在什么文件里面的

pkaq commented 2 years ago

问题已经解决 但是不妨碍这个bug的奇葩性质

解决方式为 克隆一份dataid为 a 的配置 重命名为 a.yaml, 然后 extension-config 中配置 a.yaml 后可以正常读取

@as3324

stale[bot] commented 1 year ago

Thanks for your feedback and contribution. But the issue/pull request has not had recent activity more than 180 days. This issue/pull request will be closed if no further activity occurs 7 days later. We may solve this issue in new version. So can you upgrade to newest version and retry? If there are still issues or want to contribute again. Please create new issue or pull request again.