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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52756135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 00:36:26  来源:igfitidea点击:

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

javaspringspring-bootgradlespring-data-jpa

提问by BlueScoreMan

I'm doing this project with spring boot and I tried to write some tests but sadly I get this exception stacktrace:

我正在用 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

I looked if some sort of dependency was missing in my build.gradle, but I don't think so. The BootstrapModethingy doesn't exist anywhere, not even on the Central Maven Repository. I searched through my entire project with IntelliJ for any type of BootstrapModeappearance, without any luck.

我查看了build.gradle 中是否缺少某种依赖,但我不这么认为。该BootstrapMode啄不存在任何地方,甚至没有在中央Maven仓库。我用 IntelliJ 在我的整个项目中搜索了任何类型的BootstrapMode外观,但没有任何运气。

These are my gradle dependencies: Gradle Dependencies

这些是我的 gradle 依赖项: Gradle 依赖项

This is my PostgrsJpaConfig class: PostgresJpaConfig class

这是我的 PostgrsJpaConfig 类: PostgresJpaConfig 类

采纳答案by BlueScoreMan

TL;DR: I was mixing up Spring versions. Overriding one version with another, which you shouldn't do.

TL;DR:我混淆了 Spring 版本。用另一个版本覆盖一个版本,您不应该这样做。

Instead of using the org.springframework.datadependency, I should use org.springframework.boot:spring-boot-starter-data-jpa.

而不是使用的org.springframework.data依赖,我应该使用org.springframework.boot:spring-boot-starter-data-jpa