Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoClassDefFoundError:org/springframework/data/repository/config/BootstrapMode_Java_Spring_Spring Boot_Gradle_Spring Data Jpa - Fatal编程技术网

java.lang.NoClassDefFoundError:org/springframework/data/repository/config/BootstrapMode

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

我正在用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/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由测试启动器管理)。