Skip to content
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

Spring @ConfigProperties bindings are not relaxed #12483

Closed
ntrp opened this issue Oct 2, 2020 · 5 comments · Fixed by #12547
Closed

Spring @ConfigProperties bindings are not relaxed #12483

ntrp opened this issue Oct 2, 2020 · 5 comments · Fixed by #12547
Assignees
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Milestone

Comments

@ntrp
Copy link
Contributor

ntrp commented Oct 2, 2020

Describe the bug
When defining properties with kebab case and defining pojos in camel case, the properties are not binded. The preferred behavior would be like described here: Relaxed Binding

Expected behavior
I defined a property named:
prop.name-with-dash
and a class:

@Data
@ConfigurationProperties(prefix = "prop")
public class MyProps {
   private String nameWithDash;
}

The property gets loaded correctly.

Actual behavior
The application fails with:
javax.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: prop.nameWithDash

To Reproduce
The issue is pretty straightforward that's why I am not attaching a project, if really needed let me know and I will add one.

Configuration

# Add your application.properties here, if applicable.
prop.name-with-dash=value

Environment (please complete the following information):

  • Output of uname -a or ver: Linux host 5.8.10-arch1-1 Switch to the Maven distributed copy of the SubstrateVM annotations #1 SMP PREEMPT Thu, 17 Sep 2020 18:01:06 +0000 x86_64 GNU/Linux
  • Output of java -version: openjdk version "11.0.8" 2020-07-14
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.8.1.final
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)
@ntrp ntrp added the kind/bug Something isn't working label Oct 2, 2020
@quarkusbot
Copy link

/cc @geoand

@quarkusbot quarkusbot added the area/spring Issues relating to the Spring integration label Oct 2, 2020
@rquinio
Copy link
Contributor

rquinio commented Oct 3, 2020

I don't think relaxed binding is possible, given properties names have to be known at build time...
The default for spring-boot extension should rather be kebab case given it's "recommended for use in .properties and .yml files" in the docs.
Maybe quarkus.arc.config-properties-default-naming-strategy could be used when needing to switch to camelCase/verbatim ?
The limitation of not mixing strategies would have to be documented.
There's no strategy in Quarkus for "underscore notation", but I doubt it's used a lot.

@ntrp
Copy link
Contributor Author

ntrp commented Oct 3, 2020

Fair enough about relaxed binding but then would be great letting the user decide which kind of binding to use. I don't think quarkus.arc.config-properties-default-naming-strategy is used in this case since the default is kebab-case and it is using the exact name of the property to bind.

@geoand
Copy link
Contributor

geoand commented Oct 3, 2020 via email

@gytis
Copy link

gytis commented Oct 5, 2020

Makes sense. I'll fix it.

gytis pushed a commit to gytis/quarkus that referenced this issue Oct 6, 2020
gytis pushed a commit to gytis/quarkus that referenced this issue Oct 6, 2020
geoand added a commit that referenced this issue Oct 7, 2020
…operties

Check naming strategy in Spring Boot properties #12483
@gsmet gsmet added this to the 1.9.0 - master milestone Oct 7, 2020
Sgitario added a commit to Sgitario/quarkus-test-suite that referenced this issue Aug 12, 2021
Exploratory testing for the `quarkus-spring-boot-properties` Quarkus extension. The application consists of a REST endpoint
with some different approaches to inject properties.

Current limitations:
- Relaxing name convention is not supported and it won't be supported: quarkusio/quarkus#12483
- The annotation `@ConstructorBinding` is not supported yet: quarkusio/quarkus#19364
Sgitario added a commit to Sgitario/quarkus-test-suite that referenced this issue Aug 16, 2021
Exploratory testing for the `quarkus-spring-boot-properties` Quarkus extension. The application consists of a REST endpoint
with some different approaches to inject properties.

Current limitations:
- Relaxing name convention is not supported and it won't be supported: quarkusio/quarkus#12483
- The annotation `@ConstructorBinding` is not supported yet: quarkusio/quarkus#19364
Sgitario added a commit to quarkus-qe/quarkus-test-suite that referenced this issue Aug 17, 2021
Exploratory testing for the `quarkus-spring-boot-properties` Quarkus extension. The application consists of a REST endpoint
with some different approaches to inject properties.

Current limitations:
- Relaxing name convention is not supported and it won't be supported: quarkusio/quarkus#12483
- The annotation `@ConstructorBinding` is not supported yet: quarkusio/quarkus#19364
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants