我使用Dropwizard获取这些缺少的依赖项错误:
ERROR [2013-07-31 22:17:01,918] com.sun.jersey.spi.inject.Errors: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public com.pronto.mpds.domain.MerchantProfileGroup com.pronto.mpds.service.MPDSResource.getMerchantProfiles(java.util.List,java.util.List) at parameter at index 0
SEVERE: Missing dependency for method public com.pronto.mpds.domain.MerchantProfileGroup com.pronto.mpds.service.MPDSResource.getMerchantProfiles(java.util.List,java.util.List) at parameter at index 1
SEVERE: Missing dependency for method public com.pronto.mpds.domain.MerchantCpcData com.pronto.mpds.service.MPDSResource.getMerchantCpcData(java.lang.String,com.google.common.base.Optional) at parameter at index 0
SEVERE: Missing dependency for method public com.pronto.mpds.domain.MerchantCpcData com.pronto.mpds.service.MPDSResource.getMerchantCpcData(java.lang.String,com.google.common.base.Optional) at parameter at index 1
我的资源类看起来像这样:
@Path("merchants")
public class MPDSResource {
@GET
@Path("{merchantId}/profile")
@Produces(APPLICATION_JSON)
public MerchantProfile getMerchantProfile(@PathElem("merchantId") String merchantId) {
throw new UnsupportedOperationException("not yet implemented");
}
@GET
@Path("featured")
@Produces(APPLICATION_JSON)
public FeaturedMerchantGroup getFeaturedMerchants(@RequestParam(value = "browseId") String browseId) {
throw new UnsupportedOperationException("not yet implemented");
}
@GET
@Path("profile")
@Produces(APPLICATION_JSON)
public MerchantProfileGroup getMerchantProfiles(
@RequestParam(value = "merchantIds", delimiter = "|") List<String> merchantIds,
@RequestParam(value = "selectors", delimiter = "|") List<String> selectors) {
throw new UnsupportedOperationException("not yet implemented");
}
@GET
@Path("{merchantId}/cpc")
@Produces(APPLICATION_JSON)
public MerchantCpcData getMerchantCpcData(@PathElem("merchantId") String merchantId,
@RequestParam(value = "mexpCategoryIds", delimiter = "|") Optional<List<String>> mexpCategoryIds) {
throw new UnsupportedOperationException("not yet implemented");
}
}
有四种方法,但错误只发生在采用多个参数的方法上。
以下是我的球衣依赖:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.14</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.14</version>
</dependency>
我已经确认我在Maven导入中使用了一致的Jersey版本。我已经确认包含上述Resource类的Web模块在包含自定义PathElem和RequestParam类的包上包含Maven依赖项。我想不出任何其他可能性。有谁知道如何解决这个问题?
答案 0 :(得分:2)
我还将这个问题发布到了dropwizard邮件列表,Coda Hale回答说:“你似乎将Spring MVC注释与Jersey混合在一起。我从来没有尝试过,但是如果有效的话,我会感到惊讶。我会建议使用标准的JAX-RS @PathParam和朋友。“ HTH别人。
答案 1 :(得分:0)
我正在使用@FormParam。但将其更改为@RequestParam解决了这个问题。