Make @ConditionalOnProperty @Repeatable
See original GitHub issueI have a class that requires a couple of configuration properties to be set in order to instantiate a service, and also an enabled
flag to turn off that autoconfig. While I’d like a simpler setup (#2312), in the meantime I’m trying to use @ConditionalOnProperty
to check whether the properties are available. Since enabled
defaults to true
, I want it to matchIfMissing
, but obviously not the other actual configuration properties.
However, matchIfMissing
(and havingValue
) apply to all of the properties in the annotation. I would like to be able to repeat the annotation to specify multiple property names that have different presence/value matching parameters.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:30
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Spring @ConditionalOnProperty havingValue = "value1" or ...
The annotations @ConditionalOnProperty and @ConditionalOnExpression both do NOT have the java.lang.annotation.Repeatable annotation so you ...
Read more >Spring @ConditionalOnProperty havingValue = "value1" or ...
Coding example for the question Spring @ConditionalOnProperty havingValue ... a value of value1 or value2 you would create an AnyNestedCondition like this:
Read more >The Spring @ConditionalOnProperty Annotation - Baeldung
Now let's see how to make use of the @ConditionalOnProperty annotation. Let's configure the NotificationSender bean in such a way that it'll ...
Read more >spring-projects/spring-boot - Gitter
Sadly cannot do it in Java 7 ... So 2 @ConditionalOnProperty annotations on the same bean ... You were referring to repeatable annotations...
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
It would be nice if this feature would come soon. It is much more easier to use multiple
@ConditionalOnProperty
+1