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** nested exception is java.lang.ExceptionInInitializerError
‘minioClient’ threw exception;
查看代码发现:
文章图片
也就是初始化 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());
}
}
报错信息:
文章图片
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的依赖问题
文章图片
新增
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
推荐阅读
- MyBatis|Spring Boot(十)(Druid的监控统计和多数据源配置)
- java|EasyExcel 在java中实现从数据库导入导出
- Java基础与算法|Linux学习(二)---实操篇1远程登录
- poi|poi之----删除Row的实现,包括合并单元格以及图片数据
- MyBatisPlus|MyBatis-Plus工具
- 还在使用Java8( 这5个Java17新功能,你会喜欢的)
- vue|基于spring cloud + nacos + gateway + ssm+的学生管理系统
- vue|2022 年最新前端 Vue 项目重构总结
- CISC 360 Piazza