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

我似乎缺少依赖但无法找到解决方案……我已确保所有jersey版本都与此处的答案相同。

错误:

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 

使用的依赖关系:

  com.sun.jersey jersey-servlet 1.17   com.sun.jersey.contribs jersey-multipart 1.17   com.sun.jersey jersey-json 1.17   com.sun.jersey jersey-bundle 1.17   org.jvnet mimepull 1.6  

发生错误的代码:

 @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来说还不够好!