首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Minio Client:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;的弹簧引导不存在错误

使用Minio Client:okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;的弹簧引导不存在错误
EN

Stack Overflow用户
提问于 2022-06-13 08:21:55
回答 1查看 368关注 0票数 1

我试图通过使用minio客户端连接到minio服务器。获取此错误:

尝试调用不存在的方法。这一企图是在以下地点进行的:

Io.minio.S3Base。(S3Base.java:104)

不存在以下方法:

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

该方法的类okhttp3.RequestBody可从以下位置获得:

jar:file:/home/user/.m2/repository/com/squareup/okhttp3/okhttp/3.14.4/okhttp-3.14.4.jar!/okhttp3/RequestBody.class

它从以下位置加载:

file:/home/user/.m2/repository/com/squareup/okhttp3/okhttp/3.14.4/okhttp-3.14.4.jar

操作:

更正应用程序的类路径,使其包含单个兼容版本的okhttp3.RequestBody

进程已完成,退出代码为0

Pom.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.tigerit.tigerhrm</groupId>
    <artifactId>tigerit-hrm-api</artifactId>
    <version>beta-1.4.0</version>
    <!--<packaging>jar</packaging>-->
    <packaging>war</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>

      <!--  &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent &ndash;&gt;
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>-->

    </parent>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <other lib versions here>   
        
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

     //some_dependecies are removed to reduce the file size
       

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <!-- log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${logger.version}</version>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>

  <!--    https://mvnrepository.com/artifact/io.minio/minio-->
        <dependency>
            <groupId>io.minio</groupId>
            <artifactId>minio</artifactId>
            <version>8.3.9</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.14.4</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <version>1.1.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/generated-sources</outputDirectory>
                            <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我使用的是java 8,我也尝试过没有在pom.xml文件中添加pom.xml依赖项。这两种情况都不管用。

EN

回答 1

Stack Overflow用户

发布于 2022-06-28 22:20:52

解决方案:尝试在pom中重写okhttp3.version属性,并将其设置为com.squareup.okhttp3:okhttp依赖项的更新版本(4.10.0适用于我)。或者自己显式地设置这个依赖项。或者,如果完全可行,尝试更新您的初学者-父版本(但不确定这是否适用于java 8)。

推理: maven (或者,在我的例子中是gradle)获取一个较旧版本的okhttp库的原因是,在2.7之前的版本中,这个特定库版本在春季引导依赖项中不幸地被固定住了:

代码语言:javascript
复制
<okhttp3.version>3.14.9</okhttp3.version>

在2.7,他们把它改为4.9.3

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72599713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档