spring2.x升级spring3.x 踩坑

spring-core 不支持

JAVA开发|解决报错Action: Correct the classpath of your application so that it contains compatible versions-优快云博客

The following method did not exist:

    'void org.springframework.util.Assert.notNull(java.lang.Object)'

The calling method's class, org.springframework.plugin.core.support.AbstractTypeAwareSupport$BeansOfTypeTargetSource, was loaded from the following location:

    jar:file:/E:/apache-maven-3.8.5/mvn-repo/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/support/AbstractTypeAwareSupport$BeansOfTypeTargetSource.class

The called method's class, org.springframework.util.Assert, is available from the following locations:

    jar:file:/E:/apache-maven-3.8.5/mvn-repo/org/springframework/spring-core/6.1.3/spring-core-6.1.3.jar!/org/springframework/util/Assert.class

The called method's class hierarchy was loaded from the following locations:

    org.springframework.util.Assert: file:/E:/apache-maven-3.8.5/mvn-repo/org/springframework/spring-core/6.1.3/spring-core-6.1.3.jar


上面的意思就是出现了依赖冲突,首先就是要定位是引入的哪一个包出现冲突,这里就是org.springframework.boot:spring-boot-starter-test:3.2.2 :

image.png

原因就在于我们升级了Spring3.x,但测试的时候还是依赖的旧的Spring-core就导致不兼容,查看网上有用exclusion排除spring-core的依赖,参考下面教程一样:

JAVA开发|解决报错Action: Correct the classpath of your application so that it contains compatible versions-优快云博客

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
        <exclusion>
            <artifactId>org.springframework.plugin</artifactId>
            <groupId>spring-plugin-core</groupId>
        </exclusion>
    </exclusions>
        </dependency>

但实际上还是报错,最后常用升级依赖进行解决

在pom文件中升级依赖:

        <dependency>
            <groupId>org.springframework.plugin</groupId>
            <artifactId>spring-plugin-core</artifactId>
            <version>3.0.0</version>
        </dependency>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值