Regression: Can't inject beans annotated with `@ConfigProperties`
See original GitHub issueDescribe the bug
Having:
@ConfigProperties(prefix = "server")
public class BulkOfPropertiesConfiguration {
String url;
String host;
String path;
int port;
@ConfigProperty(name = "port")
int repeatedPort;
@ConfigProperty(name = "url.with.default.found")
String urlWithDefaultAndConfigFound;
}
And this being in use in:
@Path("/bulk-properties")
public class BulkOfPropertiesResource {
@Any
@Inject
BulkOfPropertiesConfiguration config;
@GET
@Path("/url")
public String getUrl() {
return config.url;
}
The app fails to start because says that can’t find BulkOfPropertiesConfiguration:
[ERROR] Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type io.quarkus.qe.properties.bulk.BulkOfPropertiesConfiguration and qualifiers [@Any]
[ERROR] - java member: io.quarkus.qe.properties.bulk.BulkOfPropertiesResource#config
[ERROR] - declared on CLASS bean [types=[java.lang.Object, io.quarkus.qe.properties.bulk.BulkOfPropertiesResource], qualifiers=[@Default, @Any], target=io.quarkus.qe.properties.bulk.BulkOfPropertiesResource]
[ERROR] at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:567)
[ERROR] at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:470)
[ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:256)
[ERROR] ... 13 more
This is caused by this change: https://github.com/quarkusio/quarkus/pull/19965/commits/6378f80f1c4ff0ad9a50e1cc9944163e2a8eeeeb
I tried to annotate the BulkOfPropertiesConfiguration with @Unremovable
and also remove the @Any
but nothing helped.
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
- git clone
https://github.com/Sgitario/quarkus-test-suite
- cd quarkus-test-suite
- git checkout reproducer_20610
- cd properties
- mvn clean verify
Output of uname -a
or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Chapter 4. Injecting configuration values into your Quarkus ...
ConfigProperties annotation to group configuration properties. The following procedure demonstrates the use of @ConfigProperties annotation on the Quarkus ...
Read more >java - Why can't I inject one of my PoJo's with Spring's @Value ...
After checking your answer: I think the \@Bean annotation is needed but the \@Qualifier is not. The two managed beans are found without...
Read more >Contexts and Dependency Injection - Quarkus
This behavior is defined by CDI. But producer methods and fields and observer methods are discovered even if the declaring class is not...
Read more >spring read environment variable in application properties
A good read explaining the annotations involved can be found here: Spring Java ... Can Enums Be Subclassed to Add New Elements, Why...
Read more >Documentation - TestNG
Write the business logic of your test and insert TestNG annotations in your code. ... The list of groups you want to run...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Added the clarification here: https://github.com/quarkusio/quarkus/wiki/Migration-Guide-2.4#microprofile-config.
I’m not sure what exactly is not being done in the intended way. Do you mean that we cannot longer use the
@ConfigProperties
qualifier and then inject this bean using@Inject
?If so, this is the approach that was used in Quarkus 1.7 (https://quarkus.io/version/1.7/guides/config#using-configproperties). Moreover, if this is not longer supported in Quarkus 2.4 +, we should make a big note in the migration guide about the new usage of the
@ConfigProperties
as many users might still be using this approach.