Facing 'NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode' issue while running the tests
Facing 'NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode' issue while running the tests
这些是我的 pom.xml 文件中添加的 spring 相关 jar
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
我看到的错误是:
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.185 sec <<< FAILURE! - in com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests
emptyInputShouldReturnEmptyJson(com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests) Time elapsed: 1.145 sec <<< ERROR!
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/a-5594/dev/github/eps-jobs-air-offline-cancel-sync/target/classes/com/expedia/www/eps/jobs/air/offline/cancel/sync/dataaccess/WebNotifyManager.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.emptyInputShouldReturnEmptyJson(LambdaTests.java:40)
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.emptyInputShouldReturnEmptyJson(LambdaTests.java:40)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.emptyInputShouldReturnEmptyJson(LambdaTests.java:40)
sentenceShouldReturnFlatJsonWithWordsAndCounts(com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests) Time elapsed: 0.033 sec <<< ERROR!
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/a-5594/dev/github/eps-jobs-air-offline-cancel-sync/target/classes/com/expedia/www/eps/jobs/air/offline/cancel/sync/dataaccess/WebNotifyManager.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.sentenceShouldReturnFlatJsonWithWordsAndCounts(LambdaTests.java:49)
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.sentenceShouldReturnFlatJsonWithWordsAndCounts(LambdaTests.java:49)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.sentenceShouldReturnFlatJsonWithWordsAndCounts(LambdaTests.java:49)
我尝试在 pom.xml 中更改 spring/jpa 等的不同版本,但问题仍然存在。
您的 spring-data-commons
版本太旧,那个版本没有 BootstrapMode
class。请尝试将其升级到 2.2.0.RELEASE
,就像对其他 spring 依赖项所做的那样。
在您的 pom 中定义一个版本 属性 可能是个好主意:
<properties>
<spring.version>2.2.0.RELEASE</spring.version>
</properties>
然后,在你的依赖项中像这样使用它:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${spring.version}</version>
</dependency>
下次想升级时 spring,只需一个地方即可。
这些是我的 pom.xml 文件中添加的 spring 相关 jar
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
我看到的错误是:
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.185 sec <<< FAILURE! - in com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests
emptyInputShouldReturnEmptyJson(com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests) Time elapsed: 1.145 sec <<< ERROR!
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/a-5594/dev/github/eps-jobs-air-offline-cancel-sync/target/classes/com/expedia/www/eps/jobs/air/offline/cancel/sync/dataaccess/WebNotifyManager.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.emptyInputShouldReturnEmptyJson(LambdaTests.java:40)
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.emptyInputShouldReturnEmptyJson(LambdaTests.java:40)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.emptyInputShouldReturnEmptyJson(LambdaTests.java:40)
sentenceShouldReturnFlatJsonWithWordsAndCounts(com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests) Time elapsed: 0.033 sec <<< ERROR!
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/a-5594/dev/github/eps-jobs-air-offline-cancel-sync/target/classes/com/expedia/www/eps/jobs/air/offline/cancel/sync/dataaccess/WebNotifyManager.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.sentenceShouldReturnFlatJsonWithWordsAndCounts(LambdaTests.java:49)
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/repository/config/BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.sentenceShouldReturnFlatJsonWithWordsAndCounts(LambdaTests.java:49)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.BootstrapMode
at com.expedia.www.eps.jobs.air.offline.cancel.sync.LambdaTests.sentenceShouldReturnFlatJsonWithWordsAndCounts(LambdaTests.java:49)
我尝试在 pom.xml 中更改 spring/jpa 等的不同版本,但问题仍然存在。
您的 spring-data-commons
版本太旧,那个版本没有 BootstrapMode
class。请尝试将其升级到 2.2.0.RELEASE
,就像对其他 spring 依赖项所做的那样。
在您的 pom 中定义一个版本 属性 可能是个好主意:
<properties>
<spring.version>2.2.0.RELEASE</spring.version>
</properties>
然后,在你的依赖项中像这样使用它:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${spring.version}</version>
</dependency>
下次想升级时 spring,只需一个地方即可。