Reputation: 3199
Was trying to use YAML for my configs with Quarkus, and it looks like there's an issue with injecting config values to @ConfigProperty
.
How to reproduce
mvn io.quarkus:quarkus-maven-plugin:1.12.2.Final:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=getting-started \
-DclassName="org.acme.getting.started.GreetingResource" \
-Dpath="/hello"
cd getting-started
GreetingResource
@Path("/hello")
public class GreetingResource {
@ConfigProperty(name = "org.acme.getting.started.value")
String value;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "value " + value;
}
}
application.properties
org.acme.getting.started.value=8
./mvnw compile quarkus:dev
curl http://localhost:8080/hello
value 8
./mvnw quarkus:add-extension -Dextensions="config-yaml"
application.properties
and create application.yaml
."org.acme.getting.started.value": "8"
mvn clean
./mvnw compile quarkus:dev
2021-03-18 01:30:32,890 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): javax.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: org.acme.getting.started.value
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:39)
I checked both quarkus config docs and smallrye docs, didn't find any special requirements for YAML config mapping there. Also tried different formats for application.yaml
: quoted names, unquoted names, single-line, multi-line. None of those worked.
Is there anything I'm missing? Or should I report a bug?
UPD I tried breaking it down to multiline YAML like (in a way I would like to have it in my real app)
org:
acme:
getting.started:
value: 8
tried both quoted and unquoted, none of those worked. In order to make it work, you need to put each new key part to a new line, see @Roberto Cortez answer
Upvotes: 0
Views: 1757
Reputation: 1163
For the YAML configuration to work it needs to defined like:
org:
acme:
getting:
started:
value: 8
This is related with https://github.com/quarkusio/quarkus/issues/11744
Upvotes: 2