[英]Missing dependency for method public javax.ws.rs.core.Response (Upload File JAX-RS)
[英]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.