场景一:

        使用minio8.3.0版本的依赖,报下列异常:

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:105)

The following method did not exist:

    okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;

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

    jar:file:/D:/repository/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.class

The class hierarchy was loaded from the following locations:

    okhttp3.RequestBody: file:/D:/repository/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of okhttp3.RequestBody

        根据上面的异常信息分析,可能是okhttp依赖冲突造成的服务启动失败,因为minio底层要依赖okhttp进行和minio服务端进行通信,由于项目中多个依赖底层都依赖了不同版本的okhttp,导致这里的okhttp因版本不同,某些方法不可用,尝试降级minio的版本,如下:

<dependency>
    <groupId>io.minio</groupId>
    <artifactId>minio</artifactId>
    <version>8.2.1</version>
</dependency>

         降低了minio的版本之后,服务可以正常启动,不再报错,但是我在本地重新启动一个服务使用如下的依赖,8.3.0版本的minio依赖是可以正常启动的,但是该服务仅仅只有minio相关依赖如下:

<dependency>
    <groupId>io.minio</groupId>
    <artifactId>minio</artifactId>
    <version>8.3.0</version>
</dependency>

<dependency>
    <groupId>me.tongfei</groupId>
    <artifactId>progressbar</artifactId>
    <version>0.5.3</version>
</dependency>

<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>4.8.1</version>
</dependency>

         总结:最终对比发现,用上述依赖的时候,8.3.0版本的依赖是可以正常启动的,说明原服务中的okhttp版本太低导致和8.3.0版本的minio不兼容,导致启动失败

场景二:

        当上传文件过大,导致服务报错异常,需要添加如下配置:

spring:
   servlet:
      multipart:
      max-file-size: 100MB
      max-request-size: 100MB

         上面的配置就是修改默认上传文件大小,默认是1MB

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐