PrepZone Logo
PrepZone
Back to Spring Boot

Spring Boot · Medium

What is the difference between @ConditionalOnClass and @ConditionalOnMissingBean?

Spring BootAuto-Config & StartersConditional BeansSeniorStaff

Answer preview

@ConditionalOnClass — applies the configuration only if the specified class(es) are present on the classpath. Used to activate configuration for a library that may or may not be a dependency. Example: @ConditionalOnClass(HikariDataSource.class) — HikariCP auto-configuration only …