Skip to content

从 2023.0.3.3 升级到 2025.1.0.0 后,无法从 Nacos 配置中心正确读取配置 #4293

@troyzhxu

Description

@troyzhxu

升级前后版本

  • Nacos Server 2.1.2

升级前

  • SpringBoot 3.3.13
  • SpringCloud 2023.0.6
  • SpringCloudAlibaba 2023.0.3.3

升级后

  • SpringBoot 4.0.5
  • SpringCloud 2025.1.1
  • SpringCloudAlibaba 2025.1.0.0

bootstrap.yml 配置

升级前(功能一切正常)

spring:
  application:
    name: jupiter-web-system
  cloud:
    nacos:
      config:
        file-extension: yml
  config:
    import:
      - nacos:${spring.application.name}?refreshEnabled=true
  cloud:
    nacos:
      server-addr: xxxxx:8848
      username: xxx
      password: xxx

升级后(找到不到配置)

警告日志信息

18:51:10.713 WARN  [Nacos Config] config[dataId=jupiter-web-system, group=DEFAULT_GROUP] is empty

尝试了以下几种形式,都不行

  • 加后缀(不行)
spring:
  application:
    name: jupiter-web-system
  cloud:
    nacos:
      config:
        file-extension: yml
  config:
    import:
      - nacos:${spring.application.name}.yml?refreshEnabled=true
  cloud:
    nacos:
      server-addr: xxxxx:8848
      username: xxx
      password: xxx
  • 加 optional(不行)
spring:
  application:
    name: jupiter-web-system
  cloud:
    nacos:
      config:
        file-extension: yml
  config:
    import:
      - optional:nacos:${spring.application.name}?refreshEnabled=true
  cloud:
    nacos:
      server-addr: xxxxx:8848
      username: xxx
      password: xxx
  • 加 namespace (不行)
spring:
  application:
    name: jupiter-web-system
  cloud:
    nacos:
      config:
        file-extension: yml
  config:
    import:
      - nacos:${spring.application.name}?refreshEnabled=true
    namespace: public
  cloud:
    nacos:
      server-addr: xxxxx:8848
      username: xxx
      password: xxx
  • 把 import 路径写完整 (不行)
spring:
  application:
    name: jupiter-web-system
  cloud:
    nacos:
      config:
        file-extension: yml
  config:
    import:
      - nacos:${spring.application.name}?server-addr=xxxxx:8848&namespace=&group=DEFAULT_GROUP&refreshEnabled=true
  cloud:
    nacos:
      server-addr: xxxxx:8848
      username: xxx
      password: xxx

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions