Skip to content

Nacos config refresh does not work with spring.config.import on 2025.0.x: PropertySource name mismatch and file extension lost in NacosPropertySourceRefreshListener #4331

@TAlcantara

Description

@TAlcantara

Which Component

Nacos Config (spring-alibaba-nacos-config)


Describe the bug

When using spring-alibaba-nacos-config:2025.0.0.0 with Spring Boot 3.5.9 and spring.config.import=nacos:..., remote configuration can be loaded successfully at startup, but runtime refresh does not work correctly after the config is changed in Nacos.

After debugging the refresh flow, I found two related problems:

  1. NacosPropertySourceRefreshListener cannot always locate the existing Nacos PropertySource in Environment, because the lookup key used in refresh does not match the actual property source name used by the ConfigData import path.
  2. NacosPropertySourceRefreshListener rebuilds the property source with "properties" as the file extension, which is incorrect for configs imported as yml/yaml/json/xml.

As a result, the runtime Environment still exposes old values after a Nacos config change.


Simplest demo

I do not have a public demo repo at the moment, but the issue can be reproduced with a minimal Spring Boot application using:

  • Spring Boot 3.5.9
  • spring-alibaba-nacos-config:2025.0.0.0
  • nacos-client:2.3.2
  • spring.config.import=nacos:...yml?group=DEFAULT_GROUP&refreshEnabled=true

Minimal configuration:

spring:
  application:
    name: demo-app
  config:
    import:
      - "nacos:${spring.application.name}.yml?group=DEFAULT_GROUP&refreshEnabled=true"
  nacos:
    config:
      group: DEFAULT_GROUP
      refresh-enabled: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions