minio Unsupported OkHttp library found. Must use okhttp >= 4.8.1

Viewed 1270

after using minio as instructions and fixing it with ways below, I failed.what can i do to solve this bug

        <dependency>
        <groupId>io.minio</groupId>
        <artifactId>minio</artifactId>
        <version>8.3.5</version>
        <exclusions>
            <exclusion>
                <artifactId>okhttp</artifactId>
                <groupId>com.squareup.okhttp3</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.9.3</version>
    </dependency>
</dependencies>
1 Answers

I also experienced this issues with io.minio:minio:8.3.6, but was able to force a newer version of okhttp, which works with the MinIO client library. Here is the snippet of build.gradle (should work similar with Maven):

implementation("io.minio:minio:8.3.6")    
implementation("com.squareup.okhttp3:okhttp:4.9.3")

In my case it was probably caused by spring-boot-dependencies coming with the spring dependency plugin, which manages a lot of dependencies containing also okhttp and thus forces the downgrade.

See also:

Update

With Spring Boot 2.7.0, the fix is no longer required, since the version requirements for okhttp have been updated. The MinIO dependency should work now out of the box.

Related