目录

 

1.导入依赖

2.创建spring boot工程,工程名为springboot-minio

3.配置minio配置文件

4.创建配置类MinioConfig

5.创建Minio工具类MinioUtils

6.创建测试controller类

7.启动项目测试

1.导入依赖

implementation 'io.minio:minio:8.2.2'

2.创建spring boot工程,工程名为springboot-minio

springboot跨服务器存储文件 springboot文件服务器搭建_spring

3.配置minio配置文件

minio:
  endpoint: http://10.0.1.140:9002
  accessKey: minio
  secretKey: minio123
  bucketName: test

4.创建配置类MinioConfig

package com.springboot.minio.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zsx
 */
@Data
@Configuration
public class MinioConfig {

    /**
     * 访问地址
     */
    @Value("${minio.endpoint}")
    private String endpoint;

    /**
     * accessKey类似于用户ID,用于唯一标识你的账户
     */
    @Value("${minio.accessKey}")
    private String accessKey;

    /**
     * secretKey是你账户的密码
     */
    @Value("${minio.secretKey}")
    private String secretKey;

    /**
     * 默认存储桶
     */
    @Value("${minio.bucketName}")
    private String bucketName ;

    @Bean
    public MinioClient minioClient(){
        MinioClient minioClient = MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
        return minioClient;
    }
}

5.创建Minio工具类MinioUtils

package com.springboot.minio.utils;

import io.minio.*;
import io.minio.http.Method;
import io.minio.messages.Bucket;
import io.minio.messages.DeleteObject;
import io.minio.messages.Item;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;

/**
 * MinIO工具类
 *
 * @Author zsx
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class MinioUtils {

    private final MinioClient minioClient;

    /******************************  Operate Bucket Start  ******************************/

    /**
     * 启动SpringBoot容器的时候初始化Bucket
     * 如果没有Bucket则创建
     *
     * @param bucketName
     */
    @SneakyThrows(Exception.class)
    private void createBucket(String bucketName) {
        if (!bucketExists(bucketName)) {
            minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
        }
    }

    /**
     * 判断Bucket是否存在,true:存在,false:不存在
     *
     * @param bucketName
     * @return
     */
    @SneakyThrows(Exception.class)
    public boolean bucketExists(String bucketName) {
        return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
    }

    /**
     * 获得Bucket的策略
     *
     * @param bucketName
     * @return
     */
    @SneakyThrows(Exception.class)
    public String getBucketPolicy(String bucketName) {
        return minioClient.getBucketPolicy(GetBucketPolicyArgs
                .builder()
                .bucket(bucketName)
                .build());
    }

    /**
     * 获得所有Bucket列表
     *
     * @return
     */
    @SneakyThrows(Exception.class)
    public List<Bucket> getAllBuckets() {
        return minioClient.listBuckets();
    }

    /**
     * 根据bucketName获取其相关信息
     *
     * @param bucketName
     * @return
     */
    @SneakyThrows(Exception.class)
    public Optional<Bucket> getBucket(String bucketName) {
        return getAllBuckets().stream().filter(b -> b.name().equals(bucketName)).findFirst();
    }

    /**
     * 根据bucketName删除Bucket,true:删除成功; false:删除失败,文件或已不存在
     *
     * @param bucketName
     * @throws Exception
     */
    @SneakyThrows(Exception.class)
    public void removeBucket(String bucketName) {
        minioClient.removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build());
    }

    /******************************  Operate Bucket End  ******************************/


    /******************************  Operate Files Start  ******************************/

    /**
     * 判断文件是否存在
     *
     * @param bucketName
     * @param objectName
     * @return
     */
    public boolean isObjectExist(String bucketName, String objectName) {
        boolean exist = true;
        try {
            minioClient.statObject(StatObjectArgs.builder().bucket(bucketName).object(objectName).build());
        } catch (Exception e) {
            log.error("[Minio工具类]>>>> 判断文件是否存在, 异常:", e);
            exist = false;
        }
        return exist;
    }

    /**
     * 判断文件夹是否存在
     *
     * @param bucketName
     * @param objectName
     * @return
     */
    public boolean isFolderExist(String bucketName, String objectName) {
        boolean exist = false;
        try {
            Iterable<Result<Item>> results = minioClient.listObjects(
                    ListObjectsArgs.builder().bucket(bucketName).prefix(objectName).recursive(false).build());
            for (Result<Item> result : results) {
                Item item = result.get();
                if (item.isDir() && objectName.equals(item.objectName())) {
                    exist = true;
                }
            }
        } catch (Exception e) {
            log.error("[Minio工具类]>>>> 判断文件夹是否存在,异常:", e);
            exist = false;
        }
        return exist;
    }

    /**
     * 根据文件前置查询文件
     *
     * @param bucketName 存储桶
     * @param prefix     前缀
     * @param recursive  是否使用递归查询
     * @return MinioItem 列表
     */
    @SneakyThrows(Exception.class)
    public List<Item> getAllObjectsByPrefix(String bucketName,
                                            String prefix,
                                            boolean recursive) {
        List<Item> list = new ArrayList<>();
        Iterable<Result<Item>> objectsIterator = minioClient.listObjects(
                ListObjectsArgs.builder().bucket(bucketName).prefix(prefix).recursive(recursive).build());
        if (objectsIterator != null) {
            for (Result<Item> o : objectsIterator) {
                Item item = o.get();
                list.add(item);
            }
        }
        return list;
    }

    /**
     * 获取文件流
     *
     * @param bucketName 存储桶
     * @param objectName 文件名
     * @return 二进制流
     */
    @SneakyThrows(Exception.class)
    public InputStream getObject(String bucketName, String objectName) {
        return minioClient.getObject(
                GetObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .build());
    }

    /**
     * 断点下载
     *
     * @param bucketName 存储桶
     * @param objectName 文件名称
     * @param offset     起始字节的位置
     * @param length     要读取的长度
     * @return 二进制流
     */
    @SneakyThrows(Exception.class)
    public InputStream getObject(String bucketName, String objectName, long offset, long length) {
        return minioClient.getObject(
                GetObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .offset(offset)
                        .length(length)
                        .build());
    }

    /**
     * 获取路径下文件列表
     *
     * @param bucketName 存储桶
     * @param prefix     文件名称
     * @param recursive  是否递归查找,false:模拟文件夹结构查找
     * @return 二进制流
     */
    public Iterable<Result<Item>> listObjects(String bucketName, String prefix, boolean recursive) {
        return minioClient.listObjects(
                ListObjectsArgs.builder()
                        .bucket(bucketName)
                        .prefix(prefix)
                        .recursive(recursive)
                        .build());
    }

    /**
     * 使用MultipartFile进行文件上传
     *
     * @param bucketName  存储桶
     * @param file        文件名
     * @param objectName  对象名
     * @param contentType 类型
     * @return
     */
    @SneakyThrows(Exception.class)
    public ObjectWriteResponse uploadFile(String bucketName, MultipartFile file, String objectName, String contentType) {
        InputStream inputStream = file.getInputStream();
        return minioClient.putObject(
                PutObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .contentType(contentType)
                        .stream(inputStream, inputStream.available(), -1)
                        .build());
    }

    /**
     * 上传本地文件
     *
     * @param bucketName 存储桶
     * @param objectName 对象名称
     * @param fileName   本地文件路径
     * @return
     */
    @SneakyThrows(Exception.class)
    public ObjectWriteResponse uploadFile(String bucketName, String objectName, String fileName) {
        return minioClient.uploadObject(
                UploadObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .filename(fileName)
                        .build());
    }

    /**
     * 通过流上传文件
     *
     * @param bucketName  存储桶
     * @param objectName  文件对象
     * @param inputStream 文件流
     * @return
     */
    @SneakyThrows(Exception.class)
    public ObjectWriteResponse uploadFile(String bucketName, String objectName, InputStream inputStream) {
        return minioClient.putObject(
                PutObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .stream(inputStream, inputStream.available(), -1)
                        .build());
    }

    /**
     * 创建文件夹或目录
     *
     * @param bucketName 存储桶
     * @param objectName 目录路径
     * @return
     */
    @SneakyThrows(Exception.class)
    public ObjectWriteResponse createDir(String bucketName, String objectName) {
        return minioClient.putObject(
                PutObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .stream(new ByteArrayInputStream(new byte[]{}), 0, -1)
                        .build());
    }

    /**
     * 获取文件信息, 如果抛出异常则说明文件不存在
     *
     * @param bucketName 存储桶
     * @param objectName 文件名称
     * @return
     */
    @SneakyThrows(Exception.class)
    public String getFileStatusInfo(String bucketName, String objectName) {
        return minioClient.statObject(
                StatObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .build()).toString();
    }

    /**
     * 拷贝文件
     *
     * @param bucketName    存储桶
     * @param objectName    文件名
     * @param srcBucketName 目标存储桶
     * @param srcObjectName 目标文件名
     */
    @SneakyThrows(Exception.class)
    public ObjectWriteResponse copyFile(String bucketName, String objectName, String srcBucketName, String srcObjectName) {
        return minioClient.copyObject(
                CopyObjectArgs.builder()
                        .source(CopySource.builder().bucket(bucketName).object(objectName).build())
                        .bucket(srcBucketName)
                        .object(srcObjectName)
                        .build());
    }

    /**
     * 删除文件
     *
     * @param bucketName 存储桶
     * @param objectName 文件名称
     */
    @SneakyThrows(Exception.class)
    public void removeFile(String bucketName, String objectName) {
        minioClient.removeObject(
                RemoveObjectArgs.builder()
                        .bucket(bucketName)
                        .object(objectName)
                        .build());
    }

    /**
     * 批量删除文件
     *
     * @param bucketName 存储桶
     * @param keys       需要删除的文件列表
     * @return
     */
    public void removeFiles(String bucketName, List<String> keys) {
        List<DeleteObject> objects = new LinkedList<>();
        keys.forEach(s -> {
            objects.add(new DeleteObject(s));
            try {
                removeFile(bucketName, s);
            } catch (Exception e) {
                log.error("[Minio工具类]>>>> 批量删除文件,异常:", e);
            }
        });
    }

    /**
     * 获取文件外链
     *
     * @param bucketName 存储桶
     * @param objectName 文件名
     * @param expires    过期时间 <=7 秒 (外链有效时间(单位:秒))
     * @return url
     */
    @SneakyThrows(Exception.class)
    public String getPresignedObjectUrl(String bucketName, String objectName, Integer expires) {
        GetPresignedObjectUrlArgs args = GetPresignedObjectUrlArgs.builder().expiry(expires).bucket(bucketName).object(objectName).build();
        return minioClient.getPresignedObjectUrl(args);
    }

    /**
     * 获得文件外链
     *
     * @param bucketName
     * @param objectName
     * @return url
     */
    @SneakyThrows(Exception.class)
    public String getPresignedObjectUrl(String bucketName, String objectName) {
        GetPresignedObjectUrlArgs args = GetPresignedObjectUrlArgs.builder()
                .bucket(bucketName)
                .object(objectName)
                .method(Method.GET).build();
        return minioClient.getPresignedObjectUrl(args);
    }

    /**
     * 将URLDecoder编码转成UTF8
     *
     * @param str
     * @return
     * @throws UnsupportedEncodingException
     */
    public String getUtf8ByURLDecoder(String str) throws UnsupportedEncodingException {
        String url = str.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
        return URLDecoder.decode(url, "UTF-8");
    }

    /******************************  Operate Files End  ******************************/
}

6.创建测试controller类

package com.springboot.minio.controller;

import com.springboot.minio.config.MinioConfig;
import com.springboot.minio.utils.MinioUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;

/**
 * @Author zsx
 * @Date 2022/2/28 11:03
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/test")
@AllArgsConstructor
public class TestController {

    private final MinioUtils minioUtils;
    private final MinioConfig minioConfig;

    /**
     * 文件上传
     * @param file
     */
    @PostMapping("/upload")
    public void upload(@RequestParam("file") MultipartFile file)  {
        try {
            //文件名
            String fileName = file.getOriginalFilename();
            String newFileName= System.currentTimeMillis()+"."+ StringUtils.substringAfterLast(fileName,".");
            //类型
            String contentType = file.getContentType();
            minioUtils.uploadFile(minioConfig.getBucketName(), file, newFileName, contentType);
        }catch (Exception e){
            log.error("上传失败");
        }
    }

    /**
     * 删除
     * @param fileName
     */
    @DeleteMapping("/")
    public void delete(@RequestParam("fileName") String fileName)  {
        minioUtils.removeFile(minioConfig.getBucketName(), fileName);
    }

    /**
     * 获取文件信息
     * @param fileName
     * @return
     */
    @GetMapping("/info")
    public String getFileStatusInfo(@RequestParam("fileName") String fileName)  {
        return minioUtils.getFileStatusInfo(minioConfig.getBucketName(), fileName);
    }

    /**
     * 获取文件外链
     * @param fileName
     * @return
     */
    @GetMapping("/url")
    public String getPresignedObjectUrl(@RequestParam("fileName") String fileName)  {
        return minioUtils.getPresignedObjectUrl(minioConfig.getBucketName(), fileName);
    }

    /**
     * 文件下载
     * @param fileName
     * @param response
     */
    @GetMapping("/download")
    public void download(@RequestParam("fileName") String fileName, HttpServletResponse response)  {
        try {
            InputStream fileInputStream = minioUtils.getObject(minioConfig.getBucketName(), fileName);
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/force-download");
            response.setCharacterEncoding("UTF-8");
            IOUtils.copy(fileInputStream,response.getOutputStream());
        }catch (Exception e){
            log.error("下载失败");
        }
    }
}

7.启动项目测试

通过postman请求接口测试,然后观看minio后台是否有上传的文件

springboot跨服务器存储文件 springboot文件服务器搭建_服务器_02

 通过测试我们发现上传文件成功了,后台有两个文件一个png格式的一个mp4格式的

springboot跨服务器存储文件 springboot文件服务器搭建_分布式_03

 注意:如果启动项目出现下面错误,把minio的版本更换为低版本的,我最初用的是8.3.6版本的出现下面错误,后面一直调低版本发现8.2.2是可以的。

"D:\Program Files\Java\jdk-11.0.10\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63490,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:C:\Users\zsx\AppData\Local\JetBrains\IntelliJIdea2021.1\groovyHotSwap\gragent.jar -javaagent:C:\Users\zsx\AppData\Local\JetBrains\IntelliJIdea2021.1\captureAgent\debugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\myproject\springboot-minio\build\classes\java\main;D:\myproject\springboot-minio\build\resources\main;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.projectlombok\lombok\1.18.22\9c08ea24c6eb714e2d6170e8122c069a0ba9aacf\lombok-1.18.22.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\io.minio\minio\8.3.6\e6b8b7ac9f3e30f5d1b179ff3cc798d63cd2ba90\minio-8.3.6.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.6.4\4aa74a41a8ff99e256433805b0ee63a6053d6b6c\spring-boot-starter-web-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.carrotsearch.thirdparty\simple-xml-safe\2.7.1\45fda5ac6087bc82a209d8cdb73f8d0dbdcfc7b\simple-xml-safe-2.7.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.google.guava\guava\30.1.1-jre\87e0fd1df874ea3cbe577702fe6f17068b790fd8\guava-30.1.1-jre.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.squareup.okhttp3\okhttp\3.14.9\3e6d101343c7ea687cd593e4990f73b25c878383\okhttp-3.14.9.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.13.1\51ae921a2ed1e06ca8876f12f32f265e83c0b2b8\jackson-core-2.13.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.13.1\698b2d2b15d9a1b7aae025f1d9f576842285e7f6\jackson-databind-2.13.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.13.1\1cbcbe4623113e6af92ccaa89884a345270f1a87\jackson-annotations-2.13.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.69\91e1628251cf3ca90093ce9d0fe67e5b7dab3850\bcprov-jdk15on-1.69.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.21\4ec95b60d4e86b5c95a0e919cb172a0af98011ef\commons-compress-1.21.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.xerial.snappy\snappy-java\1.1.8.4\66f0d56454509f6e36175f2331572e250e04a6cc\snappy-java-1.1.8.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.6.4\9aa13f5bd6e09510d89ec3874118f027613a9565\spring-boot-starter-json-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.6.4\31adf5f726b6a5703815b99056110b96db7eff58\spring-boot-starter-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.6.4\7f5937c60c8f556402e4970c4bb657f92b653f2b\spring-boot-starter-tomcat-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.3.16\18e0d7a9cf1c43b100296f86f61b58821dd1e6b9\spring-webmvc-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-web\5.3.16\224ae9b45e138034980a423e2f85d7bd63539a49\spring-web-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.google.guava\failureaccess\1.0.1\1dcf1de382a0bf95a3d8b0849546c88bac1292c9\failureaccess-1.0.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.google.guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\b421526c5f297295adef1c886e5246c39d4ac629\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.checkerframework\checker-qual\3.8.0\6b83e4a33220272c3a08991498ba9dc09519f190\checker-qual-3.8.0.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.google.errorprone\error_prone_annotations\2.5.1\562d366678b89ce5d6b6b82c1a073880341e3fba\error_prone_annotations-2.5.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.google.j2objc\j2objc-annotations\1.3\ba035118bc8bac37d7eff77700720999acd9986d\j2objc-annotations-1.3.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.squareup.okio\okio\1.17.2\78c7820b205002da4d2d137f6f312bd64b3d6049\okio-1.17.2.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.13.1\8ecfa9bcd714269fdf22c33f9fd00d0643bd0e21\jackson-datatype-jdk8-2.13.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.13.1\1ece5a87b59701328215e0083448b4d451857cbd\jackson-datatype-jsr310-2.13.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.13.1\cbeec2259213c555ef451a2e05f35ed1dbfbf799\jackson-module-parameter-names-2.13.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.6.4\36e75a2781fc604ac042945eed8be2fe049731df\spring-boot-autoconfigure-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.6.4\356c0ee25794ca46d8344d13cffbc30bfae1dc0e\spring-boot-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.6.4\e8bab752fd29797df304ef2ad8575e5392d96c4c\spring-boot-starter-logging-2.6.4.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.16\db1b277cd548c725144580dda8703ce179fb3769\spring-core-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.29\6d0cdafb2010f1297e574656551d7145240f6e25\snakeyaml-1.29.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.58\be15775c1abc7fd9b8fda38a8991463e04de656f\tomcat-embed-websocket-9.0.58.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.58\5166fd9f6ffef571c22265c84a0b4354a835d4d2\tomcat-embed-core-9.0.58.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.58\a82095439a98c29b3d7eb136e76e0283bf3f005f\tomcat-embed-el-9.0.58.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.16\efb9c749b335bf62dc07c1674e9d76d382a027e5\spring-context-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.16\831a17ce70686c571f3c05c4bcfb81012c5814df\spring-expression-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.16\d61c0545e0395de608be52db1cccb60ba841a26b\spring-aop-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.16\15decec5cea7a91423272daaae6f5d050c23cf3b\spring-beans-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.10\f69d97ef3335c6ab82fc21dfb77ac613f90c1221\logback-classic-1.2.10.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.17.1\3619fd18278a1a895c1dca8c5be002768071a20e\log4j-to-slf4j-2.17.1.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.36\ed46d81cef9c412a88caef405b58f93a678ff2ca\jul-to-slf4j-1.7.36.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.16\18d422952e0ce534c2b0ac8b47176c2432fb7e78\spring-jcl-5.3.16.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.10\5328406bfcae7bcdcc86810fcb2920d2c297170d\logback-core-1.2.10.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.36\6c62681a2f655b49963a5983b8b0950a6120ae14\slf4j-api-1.7.36.jar;D:\Program Files\gradle-7.0\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.17.1\d771af8e336e372fb5399c99edabe0919aeaf5b2\log4j-api-2.17.1.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.1\lib\idea_rt.jar" com.springboot.minio.SpringbootMinioApplication
Connected to the target VM, address: '127.0.0.1:63490', transport: 'socket'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.4)

2022-02-28 11:38:23.854  INFO 2196 --- [           main] c.s.minio.SpringbootMinioApplication     : Starting SpringbootMinioApplication using Java 11.0.10 on LAPTOP-9ULI7SF5 with PID 2196 (D:\myproject\springboot-minio\build\classes\java\main started by zsx in D:\myproject\springboot-minio)
2022-02-28 11:38:23.858  INFO 2196 --- [           main] c.s.minio.SpringbootMinioApplication     : No active profile set, falling back to 1 default profile: "default"
2022-02-28 11:38:24.631  INFO 2196 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-02-28 11:38:24.639  INFO 2196 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-02-28 11:38:24.639  INFO 2196 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.58]
2022-02-28 11:38:24.719  INFO 2196 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-02-28 11:38:24.719  INFO 2196 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 817 ms
2022-02-28 11:38:24.786  WARN 2196 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testController' defined in file [D:\myproject\springboot-minio\build\classes\java\main\com\springboot\minio\controller\TestController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'minioUtils' defined in file [D:\myproject\springboot-minio\build\classes\java\main\com\springboot\minio\utils\MinioUtils.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'minioClient' defined in class path resource [com/springboot/minio/config/MinioConfig.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
2022-02-28 11:38:24.789  INFO 2196 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-02-28 11:38:24.801  INFO 2196 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-28 11:38:24.820 ERROR 2196 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

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:/Program%20Files/gradle-7.0/caches/modules-2/files-2.1/io.minio/minio/8.3.6/e6b8b7ac9f3e30f5d1b179ff3cc798d63cd2ba90/minio-8.3.6.jar!/io/minio/S3Base.class

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

    jar:file:/D:/Program%20Files/gradle-7.0/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.14.9/3e6d101343c7ea687cd593e4990f73b25c878383/okhttp-3.14.9.jar!/okhttp3/RequestBody.class

The called method's class hierarchy was loaded from the following locations:

    okhttp3.RequestBody: file:/D:/Program%20Files/gradle-7.0/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.14.9/3e6d101343c7ea687cd593e4990f73b25c878383/okhttp-3.14.9.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes io.minio.S3Base and okhttp3.RequestBody

Disconnected from the target VM, address: '127.0.0.1:63490', transport: 'socket'

Process finished with exit code 1