• 整合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包。

    
            <dependency>
                <groupId>io.miniogroupId>
                <artifactId>minioartifactId>
                <version>8.5.2version>
                <exclusions>
                    <exclusion>
                        <groupId>com.squareup.okhttp3groupId>
                        <artifactId>okhttpartifactId>
                    exclusion>
                exclusions>
            dependency>
            <dependency>
                <groupId>com.squareup.okhttp3groupId>
                <artifactId>okhttpartifactId>
                <version>4.9.0version>
            dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    就像上述代码一样,这样就可以解决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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

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

    okhttp版本冲突

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

    okhttpmaven依赖

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

    okhttp依赖版本控制

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

    okhttp版本号

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

    版本号指定

    
            <dependency>
                <groupId>io.miniogroupId>
                <artifactId>minioartifactId>
                <version>8.5.2version>
                <exclusions>
                    <exclusion>
                        <groupId>com.squareup.okhttp3groupId>
                        <artifactId>okhttpartifactId>
                    exclusion>
                exclusions>
            dependency>
            <dependency>
                <groupId>com.squareup.okhttp3groupId>
                <artifactId>okhttpartifactId>
                <version>${okhttp3.version}version>
            dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
  • 相关阅读:
    uni-app的下拉搜索选择组合框
    基于JAVA+SpringMVC+MYSQL的网上人才招聘系统
    深度学习模型部署 C++学习经历
    我的十年编程路 2017年篇
    IDEA2023 常用配置(JDK/系统设置等常用配置)
    餐饮行业离职证明申请范文,共计20篇
    “阿里爸爸”又爆新作!Github新开源303页Spring全家桶高级笔记
    makefile学习汇总
    MySQL查询成本
    Oracle技术分享:检查是否存在坏块的一些方法
  • 原文地址:https://blog.csdn.net/m0_62943596/article/details/132995017