首页 > 解决方案 > Jersey 3.0.1 - 无法从 FormDataBodyPart 获取 MediaType

问题描述

我已将我在 gradle 中的项目依赖项从 compile("org.glassfish.jersey.media:jersey-media-multipart:2.3.2") 更新为 compile("org.glassfish.jersey.media:jersey-media-multipart:3.0 .1")

我收到以下错误,试图检查代码以查看是否会指向从 FormDataBodyPart 获取 MediaType 的方向,但无法弄清楚,我应该在哪里获得 Jersey 3 中的 Mediatype?

private boolean isFileChecksOk(FormDataContentDisposition fileDisposition, FormDataBodyPart body, byte[] bytes) {

        boolean mediaTypeOk = body.getMediaType().getSubtype().equalsIgnoreCase(excelMediaType);
        ...
        ...    

}

error: cannot access MediaType
        boolean mediaTypeOk = body.getMediaType().getSubtype().equalsIgnoreCase(excelMediaType);
                                               ^
  class file for jakarta.ws.rs.core.MediaType not found

build.gradle 依赖:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.4.3")
    }
}
dependencies {

    implementation 'junit:junit:4.13.2'

    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework.boot:spring-boot-starter-jersey")
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-boot-starter-jetty")
    compile("org.springframework.boot:spring-boot-starter-mail")
    compile("org.springframework.boot:spring-boot-starter-actuator")

    compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
    compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
    compile("com.fasterxml.woodstox:woodstox-core:6.2.4")

    compile("org.glassfish.jersey.media:jersey-media-multipart:3.0.1")
    compile("net.java.dev.msv:msv-core:2013.6.1")
    compile("com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.6")
    compile('org.apache.commons:commons-lang3:3.12.0')
    compile('commons-io:commons-io:2.8.0')
    compile('org.apache.commons:commons-compress:1.20')
    compile('org.apache.poi:poi-ooxml:4.1.2')
    compile('org.apache.xmlbeans:xmlbeans:3.1.0')
    compile('com.monitorjbl:xlsx-streamer:2.1.0')
    compile('com.zaxxer:HikariCP')
    compile("org.quartz-scheduler:quartz:2.3.2"){
        exclude group: 'com.zaxxer', module: 'HikariCP-java7'
    }
    compile('no.applikativ:twistgrid-builder:2.0.0')
    compile('org.apache.tika:tika-parsers:1.25')
    testCompile("org.springframework.boot:spring-boot-starter-test")

    slowtestCompile("org.latencyutils:LatencyUtils:2.0.3")    slowtestCompile("org.junit.platform:junit-platform-console-standalone:1.7.0")


}

TIA

标签: javajerseyjersey-3.0

解决方案


推荐阅读