簡體   English   中英

Maven jersey-multipart 缺少 javax.ws.rs.core.Response 的依賴項

[英]Maven jersey-multipart missing dependency for javax.ws.rs.core.Response

我似乎缺少依賴項,但找不到解決方案...我已確保所有球衣版本都與此處的回答相同。

錯誤:

  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

使用的依賴項:

<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>

發生錯誤的代碼:

@POST
@Path("copy")
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail);

有任何想法嗎? 非常感謝,弗蘭克

是的,找到了!

顯然依賴關系沒問題。

將這些添加到我的導入中

import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;

並將代碼更改為

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

現在突然一切正常! 所以希望我能幫助其他有同樣問題的人......

@FormDataParam似乎對@Consumes注釋非常挑剔。 請注意(與其他所有內容不同)將此注釋放在方法的接口定義上對於@FormDataParam來說還不夠好!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM