Skip to content

feature: config support profile and multiple values (#3552) - #3553

Open
wangYX657211334 wants to merge 2 commits into
alibaba:2021.xfrom
wangYX657211334:feature-config-supported-load-profile
Open

feature: config support profile and multiple values (#3552)#3553
wangYX657211334 wants to merge 2 commits into
alibaba:2021.xfrom
wangYX657211334:feature-config-supported-load-profile

Conversation

@wangYX657211334

Copy link
Copy Markdown

'spring.config.import with nacos' support profile and multiple values

Describe what this PR does / why we need it

Keep consistent with spring boot config resolver behavior

Does this pull request fix one issue?

#3552

Describe how you did it

modify com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolver

  1. each location splice profile
  2. each location spilt

Describe how to verify it

#3552

Special notes for reviews

'spring.config.import with nacos' support profile and multiple values
@CLAassistant

CLAassistant commented Dec 22, 2023

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gebing

gebing commented Mar 15, 2024

Copy link
Copy Markdown

that's the wanted feature, pls merge ASAP

@shiyiyue1102

Copy link
Copy Markdown
Collaborator

We recommend specifying the specific dataId and group directly through spring.config.import. If you need to specify a profile, we suggest using a ${} placeholder in the dataId, such as spring.cnfig.import=nacos: application-${profile}. yml&group=mygroup

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR adds profile-specific configuration loading to NacosConfigDataLocationResolver, enabling Spring Cloud Nacos to load profile-aware config files (e.g., application-dev.yml alongside application.yml). This aligns with Spring Boot's standard config data behavior.

Review Notes

  • Feature value: Profile-specific config loading is a standard Spring Boot feature. Adding it to the Nacos config data resolver improves consistency with Spring Cloud Config and Kubernetes config providers.
  • Implementation: The getProfileConfigDataLocation() method correctly handles optional prefix, extension preservation, and query parameter positioning.
  • [Warning] Backward compatibility: This changes the config loading behavior — existing deployments that rely on the current single-file loading may see additional config files being loaded. Please document this behavior change and consider adding a property to disable profile-specific loading if needed.
  • [Info] Test coverage: Good that tests are included. Consider adding edge case tests for:
    • Config locations with query parameters (e.g., nacos:app.yml?group=xxx)
    • Multiple active profiles
    • Optional prefix handling (optional:nacos:app.yml)

Cross-repo Note

If this feature is merged, the official docs should be updated to explain profile-specific config loading behavior.


Automated review by github-manager-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants