2013-08-01 28 views
1

我得到使用Dropwizard這些丟失的依賴錯誤:Dropwizard /新澤西州:缺少對方法依賴於在指標參數X

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進口一致新澤西版本證實。我已經確認包含上述Resource類的web模塊包含對包含自定義PathElem和RequestParam類的包的Maven依賴關係。我想不出任何其他的可能性。任何人都知道如何解決這個問題?

+0

注意:我在運行時遇到這些錯誤。 – barclay

+0

注意:我將列表類型參數更改爲普通字符串類型,以查看是否可以解決該錯誤,而不是。當我在違規方法簽名中刪除其中一個參數時,它停止導致錯誤。似乎很清楚,它與方法簽名中有多個參數有關。 – barclay

+0

這個運氣好嗎? – pschuegr

回答

2

我也將問題發佈到dropwizard郵件列表中,Coda Hale回答說:「您似乎在將Spring MVC註釋與Jersey混合使用,我從來沒有嘗試過,但如果這樣做會令我感到驚訝, d建議使用標準的JAX-RS @PathParam和朋友。「 HTH別人。

0

我正在使用@FormParam。但將其更改爲@RequestParam解決了問題。

相關問題