如何在Jersey 2中使用Jira-rest-java-client

时间:2016-12-21 13:21:22

标签: jira jersey-2.0 jira-rest-api jira-rest-java-api

我试图将Jira Rest Client用于现有的Jersey项目。但它导致了依赖性冲突。

的pom.xml:

<dependency>
  <groupId>org.glassfish.jersey.containers</groupId>
  <artifactId>jersey-container-servlet</artifactId>
  <version>2.24.1</version>
</dependency>
<dependency>
  <groupId>com.atlassian.jira</groupId>
  <artifactId>jira-rest-java-client-core</artifactId>
  <version>2.0.0-m30</version>
</dependency>

以上依赖项会导致异常:

root cause: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

如果我排除com.sun.jersey:jersey-client,则前一个错误会消失。

<dependency>
  <groupId>com.atlassian.jira</groupId>
  <artifactId>jira-rest-java-client</artifactId>
  <version>1.2-m01</version>
  <exclusions>
    <exclusion>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
    </exclusion>
  </exclusions>
</dependency>

然后它导致另一个例外。 org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/atlassian/fugue/Effect

我是否有任何解决方法让Jira客户端与Jersey 2一起工作?

1 个答案:

答案 0 :(得分:1)

要从atlassian jira rest客户端中排除两个依赖项:

      <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>5.1.2-2bd0a62e</version>
        <exclusions>
          <exclusion>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
          </exclusion>
        </exclusions>
      </dependency>

您可以通过添加以下依赖项来解决您遇到的另一个问题:

      <dependency>
        <groupId>io.atlassian.fugue</groupId>
        <artifactId>fugue</artifactId>
        <version>4.7.2</version>
        <scope>provided</scope>
      </dependency>