2013-05-30 32 views
6

Tôi dường như có một sự thiếu phụ thuộc nhưng không thể tìm thấy giải pháp ... Tôi đã đảm bảo tất cả các phiên bản jersey giống hệt như được trả lời here .Maven jersey-multipart thiếu phụ thuộc cho javax.ws.rs.core.Response

Lỗi:

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 sử dụng:

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

Mã nơi lỗi xảy ra:

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

Bất kỳ ý tưởng? Xin cảm ơn trước rất nhiều, Frank

Trả lời

7

Vâng tìm thấy nó!

Dường như các phụ thuộc là OK.

thêm này để nhập khẩu của tôi

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

Và thay đổi mã để

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

Và bây giờ đột nhiên mọi thứ hoạt động! Vì vậy, hy vọng tôi có thể giúp đỡ người khác có cùng vấn đề ...

3

@FormDataParam có vẻ rất kén chọn chú thích @Consumes. Lưu ý rằng (không giống như mọi thứ khác) việc đặt chú thích này trên định nghĩa giao diện của phương thức không đủ tốt cho @FormDataParam!

Các vấn đề liên quan