in 2025 with boot 3.5 when I accidentally put the main class in the default package I got an error very similar to the OPs.
I started to look into the root cause which is
Caused by: java.lang.ClassNotFoundException: io.r2dbc.spi.ValidationDepth ...
And scratched my head for a while. What the hell my project is doing with r2bdc ?!
Fortunately I found quickly this post when I searched for the error "Failed to read candidate component class:".
After founding it I realized that there was a big WARN about the default package:
2025-07-11T12:47:18.764+02:00 INFO 3534381 --- [ main] XpathDemo : Starting XpathDemo using Java 21.0.1 with PID 3534381 (/home/riskop/IdeaProjects/java_xpath_localname_namespace_uri/target/classes started by riskop in /home/riskop/IdeaProjects/java_xpath_localname_namespace_uri) 2025-07-11T12:47:18.765+02:00 INFO 3534381 --- [ main] XpathDemo : No active profile set, falling back to 1 default profile: "default" 2025-07-11T12:47:18.792+02:00 WARN 3534381 --- [ main] ionWarningsApplicationContextInitializer :
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
Seemingly I am blind.
Anyway the full output:
:: Spring Boot :: (v3.5.3)
2025-07-11T12:47:18.764+02:00 INFO 3534381 --- [ main] XpathDemo : Starting XpathDemo using Java 21.0.1 with PID 3534381 (/home/riskop/IdeaProjects/java_xpath_localname_namespace_uri/target/classes started by riskop in /home/riskop/IdeaProjects/java_xpath_localname_namespace_uri)
2025-07-11T12:47:18.765+02:00 INFO 3534381 --- [ main] XpathDemo : No active profile set, falling back to 1 default profile: "default"
2025-07-11T12:47:18.792+02:00 WARN 3534381 --- [ main] ionWarningsApplicationContextInitializer :
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
2025-07-11T12:47:19.096+02:00 WARN 3534381 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/home/riskop/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.5.3/spring-boot-autoconfigure-3.5.3.jar!/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$PoolConfiguration.class]
2025-07-11T12:47:19.098+02:00 INFO 3534381 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-07-11T12:47:19.106+02:00 ERROR 3534381 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/home/riskop/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.5.3/spring-boot-autoconfigure-3.5.3.jar!/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$PoolConfiguration.class]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:510) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:351) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:277) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:128) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:346) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:281) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:172) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:418) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:290) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350) ~[spring-boot-3.5.3.jar:3.5.3]
at XpathDemo.main(XpathDemo.java:17) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfigurations$PoolConfiguration due to io/r2dbc/spi/ValidationDepth not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:54) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:99) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:88) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:71) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isConditionMatch(ClassPathScanningCandidateComponentProvider.java:564) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.java:547) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:471) ~[spring-context-6.2.8.jar:6.2.8]
... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: io/r2dbc/spi/ValidationDepth
at java.base/java.lang.Class.getDeclaredFields0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3473) ~[na:na]
at java.base/java.lang.Class.getDeclaredField(Class.java:2780) ~[na:na]
at org.springframework.boot.context.properties.bind.DefaultBindConstructorProvider$Constructors.isInnerClass(DefaultBindConstructorProvider.java:144) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.DefaultBindConstructorProvider$Constructors.getCandidateConstructors(DefaultBindConstructorProvider.java:134) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.DefaultBindConstructorProvider$Constructors.getConstructors(DefaultBindConstructorProvider.java:103) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.DefaultBindConstructorProvider.getBindConstructor(DefaultBindConstructorProvider.java:42) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.ValueObjectBinder$ValueObject.get(ValueObjectBinder.java:230) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.ValueObjectBinder$ValueObject.get(ValueObjectBinder.java:220) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.ValueObjectBinder.bind(ValueObjectBinder.java:77) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$6(Binder.java:488) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.fromDataObjectBinders(Binder.java:493) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$7(Binder.java:487) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:608) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:594) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:487) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:426) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:357) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:345) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:275) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:236) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfigurations$PooledConnectionFactoryCondition.getMatchOutcome(ConnectionFactoryConfigurations.java:155) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.r2dbc.spi.ValidationDepth
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
... 48 common frames omitted
Process finished with exit code 1