我正在使用 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 东西在任何地方都不存在,甚至在中央 Maven 存储库中也不存在。我使用 IntelliJ 在整个项目中搜索了任何类型的 BootstrapMode 外观,但没有任何运气。
这是我的 PostgrsJpaConfig 类: PostgresJpaConfig class
最佳答案
TL;DR: I was mixing up Spring versions. Overriding one version with another, which you shouldn't do.
我应该使用 org.springframework.boot:spring-boot-starter-data-jpa
,而不是使用 org.springframework.data
依赖项。
关于java.lang.NoClassDefFoundError : org/springframework/data/repository/config/BootstrapMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52756135/