Why is there no @ConditionalOnMissingProperty on Spring Boot
search cancel

Why is there no @ConditionalOnMissingProperty on Spring Boot

book

Article ID: 447787

calendar_today

Updated On:

Products

VMware Tanzu Platform Spring

Issue/Introduction

This KB discuss why there is no @ConditionalOnMissingProperty on Spring Boot

Resolution

There is no @ConditionalOnMissingProperty in Boot because this is intentional. As of KB writing, there was a previous request to add @ConditionalOnMissingProperty  but it was declined.
For more details on the discussion with Spring committers, please see this github issue

An alternative, on attaining custom condition is using @NoneNestedConditions 

NoneNestedConditions is a Spring Boot base class that creates composite conditions which match only when none of the nested class conditions are met. It acts as a logical NOR/NOT operator, allowing you to invert standard Spring @Conditional annotations like @ConditionalOnProperty or @ConditionalOnClass