无法创建JiraRestClient

时间:2017-09-24 17:10:53

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

我正在尝试使用基本身份验证创建JiraRestClient。

JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
URI jiraServerUri = getJiraUri();
JiraRestClient restClient =  factory
 .createWithBasicHttpAuthentication(jiraServerUri, USERNAME, PASSWORD);

但是,我得到以下例外:

Exception in thread "main" java.lang.NoSuchMethodError: com.atlassian.fugue.Option.fold(Lcom/google/common/base/Supplier;Lcom/google/common/base/Function;)Ljava/lang/Object;
    at com.atlassian.httpclient.apache.httpcomponents.proxy.ProxyConfigFactory.getProxyHost(ProxyConfigFactory.java:16)
    at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.<init>(ApacheAsyncHttpClient.java:211)
    at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.<init>(ApacheAsyncHttpClient.java:123)
    at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.doCreate(DefaultHttpClientFactory.java:68)
    at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.create(DefaultHttpClientFactory.java:35)
    at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:63)
    at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)
    at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
    at com.jira.JiraClient.getJiraRestClient(JiraClient.java:37)
    at com.jira.JiraClient.getIssue(JiraClient.java:25)
    at com.jira.JiraClient.main(JiraClient.java:20)

似乎缺少某些运行时依赖性。但不确定是哪一个。

这是我朋友的片段:

<dependencies>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>4.0.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.fugue</groupId>
        <artifactId>fugue</artifactId>
        <version>3.0.0-m007</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>atlassian-public</id>
        <url>https://packages.atlassian.com/maven/repository/public</url>
    </repository>
</repositories>

我在这里缺少什么?

3 个答案:

答案 0 :(得分:1)

我在5.2.0版中遇到了类似的错误,我可以使用下面的依赖关系来解决它,而不是直接使用jira-rest-java-client-core。

<dependency>
    <groupId>com.atlassian.jira</groupId>
    <artifactId>jira-rest-java-client-app</artifactId>
    <version>5.2.0</version>
</dependency>

答案 1 :(得分:0)

这不是因为缺少图书馆。这是因为你的pom中的赋格和jira-rest-java-client-core之间的版本不匹配。

简要地看一下source,Fugue期待JDK接口,而rest库提供番石榴接口。

尝试修复版本或根本不指定赋格曲。它应该作为传递依赖。

答案 2 :(得分:0)

与JRJC 4.0.0兼容的赋格版本为2.6.1

<dependency>
    <groupId>com.atlassian.fugue</groupId>
    <artifactId>fugue</artifactId>
    <version>2.6.1</version>
</dependency>