Skip to content

Document that property placeholders should use the canonical property name form #31309

New issue

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

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

Already on GitHub? Sign in to your account

Closed
larrywest42 opened this issue Jun 9, 2022 · 1 comment
Labels
type: documentation A documentation update
Milestone

Comments

@larrywest42
Copy link

larrywest42 commented Jun 9, 2022

This is a request to improve the documentation by mentioning that "placeholders" (the property names) must always be spelt either:

  • in the uniform format (kabob-case, kabab-case, kebab-case) as documented in Spring Boot Relaxed Binding 2.0, or
  • in the original format (camelCase, snake_case) in which the property was defined.

(I haven't considered environment variables here.)

This may seem obvious, but I could not find it documented anywhere; not

The closest I could find is in the Spring Boot Relaxed Binding 2.0 document, which only says:

We recommend that properties are stored [...] in lowercase kabab format.

I think something stronger and/or more detailed is called for.

If it would help, I'd gladly put in a PR with the additional paragraph or two, if you'll point me to the appropriate documentation (source).

Example

In case anyone doubts this behavior, I'm attaching a trivial demonstration built from start.spring.io with Spring Boot 2.7 & Java 17, but I am pretty sure this behavior dates back to 2.0, at least.

The properties in the demo:

value.camelCase=v.cC
value.uniform-format=v.u-f

second.cc-via-cc=${value.camelCase}
second.uf-via-uf=${value.uniform-format}
second.cc-via-uf=${value.camel-case}
second.uf-via-cc=${value.uniformFormat}

# The first three work as expected. The fourth, referencing a property defined
# in uniform format by using camelCase name, is not resolved.

resolving-placeholders-demo.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 9, 2022
@philwebb philwebb added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 9, 2022
@philwebb philwebb modified the milestones: 2.7.x, 2.6.x Jun 9, 2022
@philwebb philwebb changed the title Spring Boot resolution of placeholder names does not fully support "relaxed binding 2.0" - documentation enhancement Document that property placeholders should use the canonical property name form Jun 14, 2022
@philwebb philwebb modified the milestones: 2.6.x, 2.6.9 Jun 14, 2022
@philwebb
Copy link
Member

Thanks for the suggestion @larrywest42. I've added something similar to note we had in the "@ConfigurationProperties vs. @Value" section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants