Improve ConfigProperty lookup
See original GitHub issueDescription
As a:
- Application user/user of the configuration itself
- API user (application developer)
- SPI user (container or runtime developer)
- Specification implementer
…I need to be able to:
use @Inject @ConfigProperty("property.name")
instead of having to put a name attribute there
@Inject @ConfigProperty(name="property.name")
…which enables me to: simply my lookup.
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (24 by maintainers)
Top Results From Across the Web
Configuration Reference Guide - Quarkus
A configuration property lookup starts by the highest ordinal configuration source available and works it way down to other sources until a match...
Read more >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 >Configuration for MicroProfile
MicroProfile Config provides a way to look up a number of configuration properties starting with the same prefix using the @ConfigProperties ...
Read more >ConfigProperty not injecting the value into the field
ConfigProperty. Here is the sample code ... I also tried using @Inject along with @ConfigProperty but no luck. ... Improve this question.
Read more >MicroProfile Config for injecting configuration properties
The [BackedAnnotatedField] @Inject @ConfigProperty private de.rieckpil.blog. ... For a more resilient behavior, or if the config property is ...
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 FreeTop 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
Top GitHub Comments
ah. Sorry for the confusion. It was a typo. I meant
@Inject @ConfigProperty(name="customer.name", defaultValue="Bob") String name;
As mentioned in the very first comment, if someone specifies bothname
andvalue
, this should resolve to an error. Thevalue
attribute in the annotations has special meanings. Puttingvalue
in this annotation means the name of the property might not be a good fit, which is even true if this property has no other attributes. I appreciate the suggestions etc. After this conversation, I think the current usage is the best approach among others and less confusion. As an end user, I’m happy to type inname=
to make my code readable. Besides, IDE will help me anyway. With this, I’m going to close my issue.I’d like to make sure I understand this absolutely clearly.
You are proposing that:
ConfigProperty
annotation:name
,value
anddefaultValue
@ConfigProperty
is at least syntactically legal (if not semantically legal)name
andvalue
will represent exactly the same thing even though they designate completely different conceptsConfigProperty
annotation must be scanned and validated to ensure that incompatible values are not specified together, and that at least one of eithername
orvalue
is specifiedDoes that correctly represent what you are proposing?
This will almost certainly be immensely confusing to end users and consequently I object to it.
Perhaps a replacement annotation is called for instead (perhaps without default-value semantics as well, given how haphazardly #446 (and #531 and #532 and #533) was addressed, and how thorny default values are in general, and how difficult they are, therefore, to encode in the primary qualifier annotation, as many issues have borne out)?
Simpler, clearer replacement possibilities might include:
ConfigKey("foo")
ConfigKeyNamed("foo")
Value("foo")
ValueNamed("foo")
Setting("foo")
SettingNamed("foo")