有来技术官方博客,推荐关注微信公众号【有来技术】获取实时更新动态|

有来技术

园龄:10年5个月粉丝:831关注:15

2022-04-09 14:35阅读: 3629评论: 0推荐: 0

SpringBoot集成MinIO8.3.x 依赖冲突解决,至简之招覆盖spring-boot-dependencies的依赖版本声明

版本声明

  • SpringBoot 2.6.5

  • MinIO 8.3.7

报错信息

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    io.minio.S3Base.<clinit>(S3Base.java:98)

The following method did not exist:

    okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;

The calling method's class, io.minio.S3Base, was loaded from the following location:

    jar:file:/D:/Soft/apache-maven-3.8.4/repository/io/minio/minio/8.3.7/minio-8.3.7.jar!/io/minio/S3Base.class

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

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

报错分析

点开minio的pom.xml 查看okhttp 声明版本是 4.8.1,但报错提示的版本是 3.14.9,这个版本是 spring-boot-dependencies-2.6.5.xml 声明的,所以只要覆盖springboot默认声明的okhttp3版本。

解决方案

在父工程pom.xml里修改properties的版本号

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <youlai.version>2.0.0</youlai.version>
        
        <!-- 覆盖SpringBoot中okhttp3的旧版本声明,解决MinIO 8.3.x的依赖冲突 -->
        <okhttp3.version>4.8.1 </okhttp3.version>
    </properties

本文作者:有来技术

本文链接:https://www.cnblogs.com/haoxianrui/p/16121969.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   有来技术  阅读(3629)  评论(0编辑  收藏  举报
历史上的今天:
2021-04-09 Docker部署Redis集群
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起