SpringBoot integrates MinIO Java SDK to realize file storage service

MinIO is a very lightweight file storage service that can be easily combined with other applications, such as NodeJS, Redis or MySQL. MinIO is an object storage service based on the Apache License v2.0 open source protocol. It is compatible with the Amazon S3 cloud storage service interface, and is very suitable for storing large-capacity unstructured data, such as pictures, videos, log files, backup data, and container/virtual machine images, etc., and an object file can be of any size, from several kb to a maximum of 5T.

MinIO Java SDK API documentation: https://docs.min.io/docs/java-client-api-reference

Development environment: JDK1.8+SpringBoot 2.1.12.RELEASE+MinIO 8.3.7

Adding MinIO dependencies (introducing MinIO may have dependency conflicts) can resolve conflicts by itself, and only record the conflicts I encountered here.

The dependency conflict between kotlin-stdlib and okhttp3 or the version is too low, resulting in the failure to integrate MinIO. For details, see: [MinIO] Some problems encountered by SpringBoot when introducing MinIO dependencies: okhttp, kotlib-stdlib

Exclude MinIO's okhttp3 dependency and reintroduce okhttp3 and kotlin-stdlib.

<!-- Set the version number -->
<properties>
    <minio.version>8.3.7</minio.version>
    <okhttp.version>4.9.0</okhttp.version>
    <kotlin-stdlib.version>1.3.70</kotlin-stdlib.version>
</properties

<!-- MinIO Java SDK for Amazon S3 Compatible Cloud Storage -->
<dependency>
    <groupId>io.minio</groupId>
    <artifactId>minio</artifactId>
    <version>${minio.version}</version>
    <exclusions>
        <exclusion>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>${okhttp.version}</version>
</dependency>
<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-stdlib</artifactId>
    <version>${kotlin-stdlib.version}</version>
</dependency>

After resolving the conflict, you can refer to the official website API for file storage operations.

Guess you like

Origin blog.csdn.net/u014698745/article/details/123751935