1.javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,3]
Message: 文档中根元素前面的标记必须格式正确。
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,3]
Message: 文档中根元素前面的标记必须格式正确。
at io.minio.Xml.unmarshal(Xml.java:55)
at io.minio.S3Base.getRegion(S3Base.java:698)
at io.minio.S3Base.execute(S3Base.java:470)
at io.minio.S3Base.executeHead(S3Base.java:728)
at io.minio.MinioClient.bucketExists(MinioClient.java:1135)
at com.glorypan.console.utils.FileUploader.main(FileUploader.java:25)
Error occurred: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,3]
Message: 文档中根元素前面的标记必须格式正确。
HTTP trace: null
解决:
minio的官方文档有中英文两版,中文版的示例版本是7.0.2,英文版是8.3.0,如果是用docker直接pull的话,是最新版latest,pom文件引入依赖的时候要注意对应。
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.3.0</version>
</dependency>
并且 运行端口9000是api的端口和9001是网页版的端口。
docker run -p 9000:9000 -p 9001:9001 --name minio -v D:\data:/data -e "MINIO_ROOT_USER=user" -e "MINIO_ROOT_PASSWORD=password" minio/minio server /data --console-address ":9001"
即创建minioclient时要用9000,而http://localhost:9001/用于网页访问控制台。
MinioClient minioClient = MinioClient.builder()
.endpoint("http://localhost:9000/")
.credentials("user", "password")
.build();
2. Unsupported OkHttp library found. Must use okhttp >= 4.8.1
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.glorypan.console.utils.FileUploader.main(FileUploader.java:18)
Caused by: java.lang.RuntimeException: Unsupported OkHttp library found. Must use okhttp >= 4.8.1
at io.minio.S3Base.<clinit>(S3Base.java:107)
... 1 more
Caused by: java.lang.NoSuchMethodError: okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;
at io.minio.S3Base.<clinit>(S3Base.java:105)
... 1 more
解决:
minio依赖于okhttp,所以pom文件还需要引入一下okhttp。
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
</dependency>
3.Exception in thread "main" javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
Exception in thread "main" javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
at java.base/sun.security.ssl.SSLSocketInputRecord.handleUnknownRecord(SSLSocketInputRecord.java:451)
at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:175)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:110)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1369)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1278)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:401)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
at io.minio.S3Base.execute(S3Base.java:532)
at io.minio.S3Base.getRegion(S3Base.java:694)
at io.minio.S3Base.execute(S3Base.java:470)
at io.minio.S3Base.executeHead(S3Base.java:728)
at io.minio.MinioClient.bucketExists(MinioClient.java:1135)
at com.glorypan.console.utils.FileUploader.main(FileUploader.java:25)
Suppressed: javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
... 30 more
解决:http别加s就行!
MinioClient minioClient = MinioClient.builder()
.endpoint("http://localhost:9000/")
.credentials("user", "password")
.build();
minio guide:minio使用手册