1

我使用 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 依赖项。我想不出任何其他的可能性。有人知道如何解决这个问题吗?

4

2 回答 2

2

我还将问题发布到 dropwizard 邮件列表,Coda Hale 回答:“您似乎将 Spring MVC 注释与 Jersey 混合。我从未尝试过,但如果它有效,我会感到惊讶。我建议使用而是标准的 JAX-RS @PathParam 和朋友。” HTH 别人。

于 2013-08-20T14:44:28.707 回答
0

我正在使用@FormParam。但是将其更改为 @RequestParam 解决了这个问题。

于 2017-04-13T01:36:52.930 回答