java.lang.NoClassDefFoundError:org/springframework/data/repository/config/BootstrapMode
我正在用spring boot做这个项目,我试着写一些测试,但遗憾的是我得到了这个异常:java.lang.NoClassDefFoundError:org/springframework/data/repository/config/BootstrapMode,java,spring,spring-boot,gradle,spring-data-jpa,Java,Spring,Spring Boot,Gradle,Spring Data Jpa,我正在用spring boot做这个项目,我试着写一些测试,但遗憾的是我得到了这个异常: java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [somepath/config
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [somepath/config/PostgresJpaConfig.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
我查看了我的build.gradle是否缺少某种依赖性,但我不这么认为。BootstrapMode thingy不存在于任何地方,甚至不存在于中央Maven存储库中。我用IntelliJ搜索了我的整个项目,寻找任何类型的BootstrapMode外观,没有任何运气
这些是我的gradle依赖项:
这是我的PostgrsJpaConfig类:
TL;博士:我把春季的版本弄混了。用
另一个,你不应该这样做
与使用
org.springframework.data
依赖项不同,我应该使用org.springframework.boot:spring-boot-starter-data-jpa
看起来您在混合使用spring版本。因为这是新的spring-data-jpa中的一个功能。。。因此,除非您使用的是SpringBoot2.1,否则它不应该可用。因此,您可能正在覆盖build.gradle
中的版本,而您不应该这样做。因此,请在您的问题中添加build.gradle
。为什么您甚至需要PostgresJpaConfig类?@BlueScoreMan您能告诉我们您在build.gradle中使用的${springBootVersion}
的值吗?请不要将code/gradle文件作为图像发布。。。将它们作为代码发布。不要使用org.springframework.data
而是使用org.springframework.boot:springbootstarterdatajpa
。删除hibernate依赖项和AssertJ依赖项(hibernate由数据jpa启动器管理,AssertJ由测试启动器管理)。