Skip to content

Document the order of application and profile specific files - #3347

Merged
ryanjbaxter merged 1 commit into
spring-cloud:mainfrom
sharanggupta:gh-1868-document-file-precedence
Oct 15, 2026
Merged

ryanjbaxter merged 1 commit into
spring-cloud:mainfrom
sharanggupta:gh-1868-document-file-precedence

Conversation

@sharanggupta

Copy link
Copy Markdown
Contributor

Fixes #1868

The Environment Repository page explains the precedence rules in general terms. It does not say where a file named after both the application and a profile, such as foo-dev.yml, ranks against application-dev.yml, foo.yml and application.yml. The issue asks exactly that.

This adds an ordered list for the page's sample client (foo with the dev and mysql profiles), from the highest precedence to the lowest:

  1. foo-mysql.yml
  2. application-mysql.yml
  3. foo-dev.yml
  4. application-dev.yml
  5. foo.yml
  6. application.yml

The list is scoped to native, Git and SVN repositories and to one search location. Those backends build a NativeEnvironmentRepository, which sets spring.config.name to application,{application}, so Spring Boot's rules give this order. I did not check the S3 backend, which builds its Environment differently.

Testing

NativeEnvironmentRepositoryTests gets a test with the six files in one classpath location. It asserts the order of the property sources for an orders application with the dev,mysql profiles, and that the first one is orders-mysql.yml. It pins existing behaviour, so it passed on the first run. ./mvnw -pl spring-cloud-config-server -am verify -Dtest=NativeEnvironmentRepositoryTests passes, including Checkstyle and the Spring Java Format check.

The environment repository page explains the precedence rules in
general terms, but it does not say where a file named after both the
application and a profile, such as foo-dev.yml, ranks against
application-dev.yml, foo.yml and application.yml.

* List the order of these files for the sample client of the page, for
  native, Git and SVN repositories and one search location.
* Add a NativeEnvironmentRepository test that pins this order.

Fixes spring-cloudgh-1868

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
@ryanjbaxter
ryanjbaxter merged commit c08df45 into spring-cloud:main Oct 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Application- and profile-specific configuration usage - undocumented or not meant to be used?

3 participants