整合minio时出现的错误

Action:Correct the classpath of your application so that it contains compatible versions of the classes io.minio.S3Base and okhttp3.RequestBody

这个错误是我在整合minio时报的错,说实话遇到这个错误我还是很头大的,因为之前在springboot项目中整合过一次minio,当时报的错误跟这个差不多,都是okhttp版本依赖问题,之前是因为,我的minio依赖里面自带的okhttp包的版本过低,需要将minio包中的okhttp包剔除,自己手动引进一个更高版本的okhttp包。

<!--maven引入minio排除okhttp依赖并添加高版本的okhttp依赖-->
        <dependency>
            <groupId>io.minio</groupId>
            <artifactId>minio</artifactId>
            <version>8.5.2</version>
            <exclusions>
                <exclusion>
                    <groupId>com.squareup.okhttp3</groupId>
                    <artifactId>okhttp</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.0</version>
        </dependency>

就像上述代码一样,这样就可以解决okhttp版本的问题。但是这次报的错误跟上次几乎一样,追根揭底也是okhttp包版本问题,这次是版本冲突问题。

这就是这个错误奇怪的地方,发现是版本冲突后,我查看了这个项目的版本依赖,但是没有发现有关okhttp的版本冲突存在。

又从头看了一下报错信息,发现了一个奇怪的地方。

The called method's class, okhttp3.RequestBody, is available from the following locations:

    jar:file:/D:/repository/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.class

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

    okhttp3.RequestBody: file:/D:/repository/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar

它不知道从哪给我加载了一个3.14.9版本的okhttp,而我引入的依赖是4.9.0的版本,然后我又看了一下我项目引入的依赖库,确实找到了两个版本的okhttp。

okhttp版本冲突

然后我就开始找这个3.14.9版本的okhttp是从哪里引进来的,自己折腾了一大晌还是没有找到,后来就放弃了,等到第二天再来看这个错误的时候,在这个okhttp依赖旁边发现了这个

okhttpmaven依赖

本来也是没发现什么异常,就是实在没法了点了一下,就进到了这里

okhttp依赖版本控制

嘿,搁这找到了,往上翻,找到他的版本号

okhttp版本号

好家伙,原来搁这了,那现在就是想办法把这个版本号给覆盖掉就行了,在我的这个项目的父工程里加入这个okhttp的版本号,在这个项目里引用这个版本号,重新启动,问题解决。

版本号指定

<!--maven引入minio排除okhttp依赖并添加高版本的okhttp依赖-->
        <dependency>
            <groupId>io.minio</groupId>
            <artifactId>minio</artifactId>
            <version>8.5.2</version>
            <exclusions>
                <exclusion>
                    <groupId>com.squareup.okhttp3</groupId>
                    <artifactId>okhttp</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>${okhttp3.version}</version>
        </dependency>
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值