Spring @ConfigProperties bindings are not relaxed
ntrp opened this issue · 5 comments
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
orver
: Linux host 5.8.10-arch1-1 #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
orgradlew --version
): Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)
/cc @geoand
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.
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.
Makes sense. I'll fix it.