maven jersey-multipart缺少对javax.ws.rs.core.Response的依赖

Fra*_*ank 6 java eclipse jersey maven

我似乎有一个丢失的依赖,但不能找到解决办法......我确信所有的球衣版本是相同的回答在这里.

错误:

  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public abstract javax.ws.rs.core.Response com.service.copy(java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 0
Run Code Online (Sandbox Code Playgroud)

使用的依赖关系:

<dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-multipart</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.17</version>
    </dependency> 

    <dependency>
            <groupId>org.jvnet</groupId>
        <artifactId>mimepull</artifactId>
        <version>1.6</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

发生错误的代码:

@POST
@Path("copy")
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail);
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?弗兰克,非常感谢

Fra*_*ank 7

是的找到了!

显然,依赖项是可以的.

将这些添加到我的导入中

import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
Run Code Online (Sandbox Code Playgroud)

并将代码更改为

@POST
@Path("copy")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail);
Run Code Online (Sandbox Code Playgroud)

现在突然一切正常!希望我能帮助其他人解决同样的问题......