Whimusical
Whimusical

Reputation: 6649

A way to accomplish @ConditionalOn*ANY*Class?

I am using Spring Boot autoconfiguration to load a bean in the context in case there is at least one of 3 beans present.

I need something like:

@Bean
@ConditionalOnANYClass({ CreateHandler.class, UpdateHandler.class, DeleteHandler.class})

Any smart solution or out-of-the-box annotation for the logical OR?

Upvotes: 1

Views: 401

Answers (2)

Whimusical
Whimusical

Reputation: 6649

Interesting report from the very Spring Gitub Issue track: https://github.com/spring-projects/spring-boot/issues/5279

Upvotes: 0

Andy Wilkinson
Andy Wilkinson

Reputation: 116111

You can use AnyNestedCondition with one nested condition per class that you want to match.

Upvotes: 2

Related Questions