2

这些是在我的 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 等,但问题仍然存在。

4

1 回答 1

2

您的版本spring-data-commons太旧,并且该版本没有BootstrapMode类。请尝试将其升级到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,一个地方就可以了。

于 2019-10-31T17:42:09.530 回答