spring-boot从2升级,4到2.7.8和java,lang.NoClassDefFoundError:无法初始化类组织,mockito.Mockito

hfwmuf9z  于 2023-04-28  发布在  Java
关注(0)|答案(1)|浏览(189)

我已经把我的项目升级到了Spring 2。第7.8条,运行测试有困难。项目正在编译,但当前测试中有一半以上失败。父组织SpringFramework Boot -版本2。7.8,java 11我的pom看起来像这样:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
        <groupId>com.sap.cloud.security.xsuaa</groupId>
        <artifactId>xsuaa-spring-boot-starter</artifactId>
        <version>2.13.5</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <version>5.4.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.pivotal.cfenv</groupId>
        <artifactId>java-cfenv</artifactId>
        <version>2.2.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifact4.13.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.vaadin.external.google</groupId>
                <artifactId>android-json</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>2.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito2</artifactId>
        <version>2.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-core</artifactId>
        <version>2.0.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>

有什么想法吗?跟踪了一些其他关于它的线索,但没有一个解决了这个问题。

cgh8pdjw

cgh8pdjw1#

根据我的经验,有时当你想升级一些版本的spring,或者spring security,例如从spring sec 5升级到spring sec 6,你可能会遇到这样的问题(在spring sec 6中,他们已经完全删除了WebSecurityConfigurerAdapter,升级后几乎什么都不起作用)。他们改变了图书馆的实施方式。

尝试降级您的版本,或尝试跟踪spring和测试库之间的更改。

相关问题