本文我们使用springboot集成minio,这里我们没有直接使用其starter,因为在maven仓库当中只有两个版本,且使用不广泛。这里我们可以自己写一个starter,其他项目直接引用就可以了。
先说一坑,minio的中文文档版本跟最新的版本完全匹配不上,而英文官网呢,我有始终无法访问,不知道小伙伴是不是碰到同样的问题。
关于minio的搭建参考我的前一篇文章:Centos7环境下搭建minio步骤详细教程
话不多说,进入正题。
一、pom依赖
我是用的版本:
<!--https://mvnrepository.com/artifact/io.minio/minio--><dependency><groupId>io.minio</groupId><artifactId>minio</artifactId><version>8.2.1</version></dependency>
这里有一坑啊,本来我使用的是最新的8.3.0版本,当所有代码都写完后,发现启动报错:
***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody2021-08-2513:01:29.975[graph-editor:N/A][ERROR]com.vtc.core.analysis.Slf4jFailureAnalysisReporter-***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody
我以为是okhttp这个版本或者包重复的问题,一顿鼓捣,发现没用,最终解决方案是降低了minio的版本到8.2.1,遇到的小伙伴可以尝试降版本。
二、配置文件
我们需要准备以下内容,配置文件yaml中的配置,分别是minio服务地址,用户名,密码,桶名称:
minio:endpoint:http://172.16.3.28:10000accessKey:adminsecretKey:12345678bucketName:aaa
另外一部分,设置spring的上传文件最大限制,如果仍然不行,请考虑是否是网关,或nginx仍然需要配置,nginx配置在最后的配置文件中我给出了100m的大小:
spring:#配置文件上传大小限制servlet:multipart:max-file-size:100MBmax-request-size:100MB
三、配置类
此处工需要两个配置类,分别是属性配置,用来读取yaml的配置;另外是初始化MinioClient到spring容器:
importlombok.Data;importorg.springframework.boot.context.properties.ConfigurationProperties;importorg.springframework.stereotype.Component;/***description:minio配置类**@author:weirx*@time:2021/8/259:47*/@Data@Component@ConfigurationProperties(prefix="minio")publicclassMinioPropertiesConfig{/***端点*/privateStringendpoint;/***用户名*/privateStringaccessKey;/***密码*/privateStringsecretKey;/***桶名称*/privateStringbucketName;}
importio.minio.MinioClient;importorg.springframework.boot.context.properties.EnableConfigurationProperties;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;importjavax.annotation.Resource;/***description:获取配置文件信息**@author:weirx*@time:2021/8/259:50*/@Configuration@EnableConfigurationProperties(MinioPropertiesConfig.class)publicclassMinioConfig{@ResourceprivateMinioPropertiesConfigminioPropertiesConfig;/***初始化MinIO客户端*/@BeanpublicMinioClientminioClient(){MinioClientminioClient=MinioClient.builder().endpoint(minioPropertiesConfig.getEndpoint()).credentials(minioPropertiesConfig.getAccessKey(),minioPropertiesConfig.getSecretKey()).build();returnminioClient;}}
四、工具类
提供一个简易的工具类供其他服务直接调用,包括上传、下载:
importcom.baomidou.mybatisplus.core.toolkit.Constants;importcom.vtc.core.utils.DownLoadUtils;importio.minio.*;importorg.apache.commons.io.IOUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.http.HttpHeaders;importorg.springframework.http.HttpStatus;importorg.springframework.http.MediaType;importorg.springframework.http.ResponseEntity;importorg.springframework.stereotype.Component;importorg.springframework.web.multipart.MultipartFile;importjava.io.ByteArrayOutputStream;importjava.io.IOException;importjava.io.InputStream;importjava.io.UnsupportedEncodingException;importjava.net.URLEncoder;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;/***@description:minio工具类*@author:weirx*@date:2021/8/2510:03*@version:3.0*/@ComponentpublicclassMinioUtil{@Value("${minio.bucketName}")privateStringbucketName;@AutowiredprivateMinioClientminioClient;/***description:判断bucket是否存在,不存在则创建**@return:void*@author:weirx*@time:2021/8/2510:20*/publicvoidexistBucket(Stringname){try{booleanexists=minioClient.bucketExists(BucketExistsArgs.builder().bucket(name).build());if(!exists){minioClient.makeBucket(MakeBucketArgs.builder().bucket(name).build());}}catch(Exceptione){e.printStackTrace();}}/***description:上传文件**@parammultipartFile*@return:java.lang.String*@author:weirx*@time:2021/8/2510:44*/publicList<String>upload(MultipartFile[]multipartFile){List<String>names=newArrayList<>(multipartFile.length);for(MultipartFilefile:multipartFile){StringfileName=file.getOriginalFilename();String[]split=fileName.split("\\.");if(split.length>1){fileName=split[0]+"_"+System.currentTimeMillis()+"."+split[1];}else{fileName=fileName+System.currentTimeMillis();}InputStreamin=null;try{in=file.getInputStream();minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(fileName).stream(in,in.available(),-1).contentType(file.getContentType()).build());}catch(Exceptione){e.printStackTrace();}finally{if(in!=null){try{in.close();}catch(IOExceptione){e.printStackTrace();}}}names.add(fileName);}returnnames;}/***description:下载文件**@paramfileName*@return:org.springframework.http.ResponseEntity<byte[]>*@author:weirx*@time:2021/8/2510:34*/publicResponseEntity<byte[]>download(StringfileName){ResponseEntity<byte[]>responseEntity=null;InputStreamin=null;ByteArrayOutputStreamout=null;try{in=minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(fileName).build());out=newByteArrayOutputStream();IOUtils.copy(in,out);//封装返回值byte[]bytes=out.toByteArray();HttpHeadersheaders=newHttpHeaders();try{headers.add("Content-Disposition","attachment;filename="+URLEncoder.encode(fileName,Constants.UTF_8));}catch(UnsupportedEncodingExceptione){e.printStackTrace();}headers.setContentLength(bytes.length);headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);headers.setAccessControlExposeHeaders(Arrays.asList("*"));responseEntity=newResponseEntity<byte[]>(bytes,headers,HttpStatus.OK);}catch(Exceptione){e.printStackTrace();}finally{try{if(in!=null){try{in.close();}catch(IOExceptione){e.printStackTrace();}}if(out!=null){out.close();}}catch(IOExceptione){e.printStackTrace();}}returnresponseEntity;}}
关于上面的下载文件的返回值问题,我们前端统一返回是这样,如果其他项目想要使用可以自行修改啊,直接ResponseBody下载,等等的。此处主要参考如何使用MinioClient上传,下载文件就好了。
五、测试一波
我们使用了springboot集成knife4j,直接通过网关访问接口文档,postman也是一样的啊。我提供下面几个简单的接口来测试一下。
@ApiOperation(value="minio上传测试")@PostMapping("/upload")publicList<String>upload(@RequestParam(name="multipartFile")MultipartFile[]multipartFile){returnminioUtil.upload(multipartFile);}@ApiOperation(value="minio下载测试")@GetMapping("/download")publicResponseEntity<byte[]>download(@RequestParamStringfileName){returnminioUtil.download(fileName);}@ApiOperation(value="minio创建桶")@PostMapping("/existBucket")publicvoidexistBucket(@RequestParamStringbucketName){minioUtil.existBucket(bucketName);}
接口页面上传文档看看:
一个坑来了,发现返回成功了,文件名称。但是在minio的控制台没有数据啊?
一看后台报错了,好长一片:
erroroccurredErrorResponse(code=SignatureDoesNotMatch,message=Therequestsignaturewecalculateddoesnotmatchthesignatureyouprovided.Checkyourkeyandsigningmethod.,bucketName=esmp,objectName=null,resource=/esmp,requestId=169E753DE01FE2AF,hostId=29aa9dc9-661b-432e-a25f-9856ad3a8250)request={method=GET,url=http://172.16.3.28:10000/esmp?location=,headers=Host:172.16.3.28:10000Accept-Encoding:identityUser-Agent:MinIO(Windows10;amd64)minio-java/8.2.1Content-MD5:1B2M2Y8AsgTpgAmY7PhCfg==x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date:20210825T052344ZAuthorization:AWS4-HMAC-SHA256Credential=*REDACTED*/20210825/us-east-1/s3/aws4_request,SignedHeaders=content-md5;host;x-amz-content-sha256;x-amz-date,Signature=*REDACTED*}response={code=403,headers=Server:nginx/1.20.1Date:Wed,25Aug202105:23:43GMTContent-Type:application/xmlContent-Length:367Connection:keep-aliveAccept-Ranges:bytesContent-Security-Policy:block-all-mixed-contentStrict-Transport-Security:max-age=31536000;includeSubDomainsVary:OriginVary:Accept-EncodingX-Amz-Request-Id:169E753DE01FE2AFX-Content-Type-Options:nosniffX-Xss-Protection:1;mode=block}atio.minio.S3Base.execute(S3Base.java:667)atio.minio.S3Base.getRegion(S3Base.java:691)atio.minio.S3Base.putObject(S3Base.java:2003)atio.minio.S3Base.putObject(S3Base.java:1153)atio.minio.MinioClient.putObject(MinioClient.java:1666)atcom.vtc.minio.util.MinioUtil.upload(MinioUtil.java:72)atcom.mvtech.graph.ui.GraphCanvasUI.upload(GraphCanvasUI.java:84)atcom.mvtech.graph.ui.GraphCanvasUI$$FastClassBySpringCGLIB$$5138ff62.invoke(<generated>)atorg.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)atorg.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)atorg.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)atcom.baidu.unbiz.fluentvalidator.interceptor.FluentValidateInterceptor.invoke(FluentValidateInterceptor.java:211)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)atorg.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)atorg.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)atorg.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)atorg.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)atcom.mvtech.graph.ui.GraphCanvasUI$$EnhancerBySpringCGLIB$$e773947f.upload(<generated>)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:498)atorg.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)atorg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:665)atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:750)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atcom.github.xiaoymin.knife4j.spring.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atcom.github.xiaoymin.knife4j.spring.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:90)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113)atcom.botany.spore.core.page.PageRequestFilter.doFilterInternal(PageRequestFilter.java:92)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)atorg.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)atorg.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)atorg.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)atorg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)atorg.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)atorg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)atjava.lang.Thread.run(Thread.java:748)
什么原因呢?因为我的minio是集群模式的,所以我用nginx负载了,此处就报错了,关于错误的nginx配置和如何搭建环境都在我文章看开头提的上一篇文章中。
此处改成单节点的配置立马就好了,由负载端口10000改成单节点端口9000,之后就都ok了,无论上传下载:
minio:endpoint:http://172.16.3.28:9000accessKey:adminsecretKey:12345678bucketName:aaa
如何解决nginx负载的问题呢?
这个问题和nginx反向代理作转发的时候所携带的header有关系,minio在校验signature是否有效的时候,必须从http header里面获取host,而我们这里没有对header作必要的处理。所以我们需要增加以下的配置:
***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody2021-08-2513:01:29.975[graph-editor:N/A][ERROR]com.vtc.core.analysis.Slf4jFailureAnalysisReporter-***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody0
完整的nginx配置如下:
#Formoreinformationonconfiguration,see:#*OfficialEnglishDocumentation:http://nginx.org/en/docs/#*OfficialRussianDocumentation:http://nginx.org/ru/docs/usernginx;worker_processesauto;error_log/var/log/nginx/error.log;pid/run/nginx.pid;#Loaddynamicmodules.See/usr/share/doc/nginx/README.dynamic.include/usr/share/nginx/modules/*.conf;events{worker_connections1024;}http{log_formatmain'$remote_addr-$remote_user[$time_local]"$request"''$status$body_bytes_sent"$http_referer"''"$http_user_agent""$http_x_forwarded_for"';access_log/var/log/nginx/access.logmain;sendfileon;tcp_nopushon;tcp_nodelayon;keepalive_timeout65;types_hash_max_size4096;include/etc/nginx/mime.types;default_typeapplication/octet-stream;#Loadmodularconfigurationfilesfromthe/etc/nginx/conf.ddirectory.#Seehttp://nginx.org/en/docs/ngx_core_module.html#include#formoreinformation.include/etc/nginx/conf.d/*.conf;upstreamminio{server172.16.3.28:9000fail_timeout=10smax_fails=2weight=1;server172.16.3.29:9000fail_timeout=10smax_fails=2weight=1;server172.16.3.30:9000fail_timeout=10smax_fails=2weight=1;}upstreamminio-console{server172.16.3.28:10001fail_timeout=10smax_fails=2weight=1;server172.16.3.29:10001fail_timeout=10smax_fails=2weight=1;server172.16.3.30:10001fail_timeout=10smax_fails=2weight=1;}server{listen10000;root/usr/share/nginx/html;client_max_body_size100m;#文件最大不能超过100MB#Loadconfigurationfilesforthedefaultserverblock.include/etc/nginx/default.d/*.conf;location/{proxy_passhttp://minio;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-for$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$remote_addr;***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody2021-08-2513:01:29.975[graph-editor:N/A][ERROR]com.vtc.core.analysis.Slf4jFailureAnalysisReporter-***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody0}error_page404/404.html;location=/404.html{}error_page500502503504/50x.html;location=/50x.html{}}server{listen11000;root/usr/share/nginx/html;#Loadconfigurationfilesforthedefaultserverblock.include/etc/nginx/default.d/*.conf;location/{proxy_passhttp://minio-console;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-for$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$remote_addr;***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody2021-08-2513:01:29.975[graph-editor:N/A][ERROR]com.vtc.core.analysis.Slf4jFailureAnalysisReporter-***************************APPLICATIONFAILEDTOSTART***************************Description:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:io.minio.S3Base.<clinit>(S3Base.java:105)Thefollowingmethoddidnotexist:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;Themethod'sclass,okhttp3.RequestBody,isavailablefromthefollowinglocations:jar:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.classItwasloadedfromthefollowinglocation:file:/D:/apache-maven-3.6.3/repo/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jarAction:Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionofokhttp3.RequestBody0}error_page404/404.html;location=/404.html{}error_page500502503504/50x.html;location=/50x.html{}}}
再次上传测试,成功了:
到此为止就全部完成啦!需要作为starter的小伙伴不要忘记配置spring.factories.