Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Nacos的config没有被加载 #3948

Open
WuJvya opened this issue Feb 15, 2025 · 2 comments
Open

Nacos的config没有被加载 #3948

WuJvya opened this issue Feb 15, 2025 · 2 comments

Comments

@WuJvya
Copy link

WuJvya commented Feb 15, 2025

版本:
nacos服务:2.5.0
spring boot:3.2.12
spring cloud:2023.0.3
nacos discovery:2023.0.3.2
nacos-config:2023.0.3.2

bootstrap.yml 的一些配置:
spring:
cloud:
nacos:
discovery:
username: "nacos"
password: "xjRWQ5jpt9"
server-addr: "http://localhost:8848/"
config:
username: "nacos"
password: "xjRWQ5jpt9"
server-addr: "http://localhost:8848/"
file-extension: "yaml"
refresh-enabled: true

服务可以注册到 nacos,在nacos的仪表盘可以看到服务在线,但是无法获取配置信息,在启动服务的时候,没有加载 nacosconfig 相关的bean,有个警告:
2025-02-15T14:17:48.100+08:00 WARN 25716 --- [devicemanage-service] [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.cloud.nacos.NacosConfigAutoConfiguration' of type [com.alibaba.cloud.nacos.NacosConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [nacosAnnotationProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.

并且把 config 中的用户名跟密码都输错,都没有任何提示,discovery 中的输错会有提示。

@WuJvya
Copy link
Author

WuJvya commented Feb 15, 2025

nacos-config:2023.0.1.2
这个版本没有问题

@5027
Copy link

5027 commented Feb 16, 2025

spring.config.import[0]=nacos:application.properties?refresh=true
spring.config.import[1]=nacos:${spring.application.name}.properties?refresh=true

spring.cloud.nacos.config.server-addr=172...19:8848
spring.cloud.nacos.config.fileExtension=properties
spring.cloud.nacos.config.namespace=0b6f9df0-*********-260a83726ff5

spring.cloud.nacos.config.shared-configs[0].data-id=${spring.application.name}.properties
spring.cloud.nacos.config.shared-configs[0].group=DEFAULT_GROUP
spring.cloud.nacos.config.shared-configs[0].refresh=true

spring.cloud.nacos.config.shared-configs[1].data-id=application.properties
spring.cloud.nacos.config.shared-configs[1].group=DEFAULT_GROUP
spring.cloud.nacos.config.shared-configs[1].refresh=true

2023.0.1.3取消了默认拉取配置方式需要采用spring-config.import来拉取的配置

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants