eclipse Maven jersey-multipart 缺少 javax.ws.rs.core.Response 的依赖项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16831443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven jersey-multipart missing dependency for javax.ws.rs.core.Response
提问by Frank
I seem to have a missing dependency but can't find the solution... I've made sure all jersey versions are identical as answered here.
我似乎缺少依赖项,但找不到解决方案...我已确保所有球衣版本都与此处的回答相同。
Error:
错误:
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
Dependencies used:
使用的依赖项:
<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>
Code where the error happens:
发生错误的代码:
@POST
@Path("copy")
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail);
Any ideas? Thanks a lot in advance, Frank
有任何想法吗?非常感谢,弗兰克
回答by Frank
Yeah found it!
是的,找到了!
Apparently the dependencies were OK.
显然依赖关系没问题。
Added these to my imports
将这些添加到我的导入中
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
And changed the code to
并将代码更改为
@POST
@Path("copy")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response copy(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail);
And now suddenly everything works! So hope I can help someone else with the same problem...
现在突然一切正常!所以希望我能帮助其他有同样问题的人......
回答by Partly Cloudy
@FormDataParam
seems to be very fussy about the @Consumes
annotation. Note that (unlike just about everything else) placing this annotation on an interface definition of the method isn't good enough for @FormDataParam
!
@FormDataParam
似乎对@Consumes
注释很挑剔。请注意(与其他所有内容不同)将此注释放在方法的接口定义上对于@FormDataParam
!