This question is about the proper way to read configuration in a REST service in a portable way, e.g. should run on Thorntail 2.4.0 and Wildfly 15.
This was the original implementation suggested by Thorntail
@Inject
@org.wildfly.swarm.spi.runtime.annotations.ConfigurationValue("swarm.port.offset")
private Optional<String> portOffset;
This was not working in WildFly 15 so we changed this code in the following way:
@Inject
@ConfigProperty(name="swarm.port.offset")
private Optional<String> portOffset;
And provided the system property is set, it works nicely.
However, back in Thorntail, it generates the following exception:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Optional with qualifiers @ConfigProperty
at injection point [BackedAnnotatedField] @Inject @ConfigProperty private com.my-company.core.internal.util.ZookeeperRegistry.portOffset
at com.my-company.core.internal.util.ZookeeperRegistry.portOffset(ZookeeperRegistry.java:0) WELD-001475: The following beans match by type, but none have matching qualifiers: - Producer Method [Optional] with qualifiers [@Any @ConfigurationValue] declared as [[UnbackedAnnotatedMethod] @ConfigurationValue @Dependent @Produces org.wildfly.swarm.container.runtime.cdi.ConfigurationValueProducer.produceOptionalConfigValue(InjectionPoint)]
Many thanks in advance.
org.eclipse.microprofile.config:microprofile-config-api
), but not on the Thorntail MP Config fraction (io.thorntail:microprofile-config
). Isn't that the case? – Ladicek