spring|SpringBoot 集成minio MinioClient无法依赖问题-已解决

com.squareup.okhttp3 okhttp 4.9.0 io.minio minio 8.3.4

开始一直报错:
2022-03-01 15:31:44.041 WARN 66992 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘fileController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘fileServiceImpl’: Unsatisfied dependency expressed through field ‘minioTemplate’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘minioClient’ defined in class path resource [com/file/minio/MinioConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: **
Failed to instantiate [io.minio.MinioClient]: Factory method
‘minioClient’ threw exception;
** nested exception is java.lang.ExceptionInInitializerError
查看代码发现:spring|SpringBoot 集成minio MinioClient无法依赖问题-已解决
文章图片

也就是初始化 MinioClient 方法发生错误;
单独测试 初始化客户端
public class MAIN { public static void main(String[] args) throws Exception { MinioClient minioClient =MinioClient.builder() .endpoint("127.0.0.1",9000,false) .credentials("minioadmin", "minioadmin") .build(); createBucket(minioClient); } private static void createBucket(MinioClient minioClient) throws Exception{ boolean exists = minioClient .bucketExists(BucketExistsArgs.builder().bucket("miniofile").build()); if (exists) { return; } minioClient.makeBucket(MakeBucketArgs.builder().bucket("miniofile").build()); } }

报错信息:
spring|SpringBoot 集成minio MinioClient无法依赖问题-已解决
文章图片

Exception in thread "main" java.lang.ExceptionInInitializerError at com.file.minio.MAIN.main(MAIN.java:9) Caused by: java.lang.RuntimeException: Unsupported OkHttp library found. Must use okhttp >= 4.8.1 at io.minio.S3Base.(S3Base.java:100) ... 1 more Caused by: java.lang.NoSuchMethodError: kotlin.collections.ArraysKt.copyInto([B[BIII)[B

但是我的okHttp 版本是4.9.0 再看
NoSuchMethodError kotlin.collections.ArraysKt.copyInto([B[BIII)[B错误 怀疑是idea的依赖问题
spring|SpringBoot 集成minio MinioClient无法依赖问题-已解决
文章图片

新增
org.jetbrains.kotlin kotlin-stdlib 1.3.70

问题解决;
【spring|SpringBoot 集成minio MinioClient无法依赖问题-已解决】完整依赖
com.squareup.okhttp3 okhttp 4.9.0 org.jetbrains.kotlin kotlin-stdlib 1.3.70 io.minio minio 8.3.4 com.squareup.okhttp3 okhttp org.jetbrains.kotlin kotlin-stdlib

    推荐阅读