无法创建AsynchronousJiraRestClientFactory(依赖项) [英] Cannot create AsynchronousJiraRestClientFactory (Dependency Issue)

查看:80
本文介绍了无法创建AsynchronousJiraRestClientFactory(依赖项)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前用Java创建了一个轻松的客户端应用程序来批量处理票证和加快工作流,但是,我想创建一个更完整的应用程序,该应用程序利用实际的JIRA api而不是在自己的解决方案中解析JSON. 我有一个非常简单的代码块来创建客户端:

I previously made a restful client application in Java to mass-manipulate tickets and expedite workflow, however, I want to create a more holistic application that utilizes the actual JIRA api instead of parsing JSON in my own solution. I have a very simple code-block to create a client:

public class SimpleMain {
  public static void main(String[] args) {
    try {
      JiraRestClient client = new AsynchronousJiraRestClientFactory()
        .createWithBasicHttpAuthentication(new URI("https://jira.redacted.com"), "redacted", "redacted");
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
  }
}

尝试创建简单的AsynchronousJiraRestClientFactory会导致以下异常:

Attempting to create a simple AsynchronousJiraRestClientFactory results in the following exception:

15:12:06.625 [main] DEBUG c.a.j.r.c.i.a.AsynchronousHttpClientFactory$MavenUtils - Could not find version for maven artifact com.atlassian.jira:jira-rest-java-com.atlassian.jira.rest.client
15:12:06.633 [main] DEBUG c.a.j.r.c.i.a.AsynchronousHttpClientFactory$MavenUtils - Got the following exception
java.lang.NullPointerException: null
at java.util.Properties$LineReader.readLine(Properties.java:434) ~[na:1.8.0_51]
at java.util.Properties.load0(Properties.java:353) ~[na:1.8.0_51]
at java.util.Properties.load(Properties.java:341) ~[na:1.8.0_51]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory$MavenUtils.getVersion(AsynchronousHttpClientFactory.java:158) ~[jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory$RestClientApplicationProperties.getVersion(AsynchronousHttpClientFactory.java:121) [jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.getUserAgent(DefaultHttpClient.java:168) [atlassian-httpclient-apache-httpcomponents-0.13.2.jar:na]
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:139) [atlassian-httpclient-apache-httpcomponents-0.13.2.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53) [jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35) [jira-rest-java-client-core-3.0.0.jar:na]
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42) [jira-rest-java-client-core-3.0.0.jar:na]
at jiratest.SimpleMain.main(SimpleMain.java:13) [classes/:na]
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.nio.client.HttpAsyncClient.start()V
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:162)
Disconnected from the target VM, address: '127.0.0.1:53429', transport: 'socket'
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53)
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 jiratest.SimpleMain.main(SimpleMain.java:13)

据我所读,这是一个依赖问题,因为库不同.这是我正在使用的:

From what I have been reading, this is a dependency issue because of differing libraries. Here is what I'm using:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <pojomatic.version>2.0.1</pojomatic.version>
    <jira-api.version>6.1.1</jira-api.version>
    <jira-rest-java-client-core.version>3.0.0</jira-rest-java-client-core.version>
    <httpcore.version>4.4.1</httpcore.version>
    <commons-io.version>2.4</commons-io.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-api</artifactId>
        <version>${jira-api.version}</version>
    </dependency>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>${jira-rest-java-client-core.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>${httpcore.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>${httpcore.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore-nio</artifactId>
        <version>${httpcore.version}</version>
    </dependency>

    <dependency>
        <groupId>org.pojomatic</groupId>
        <artifactId>pojomatic</artifactId>
        <version>${pojomatic.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-batch</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

有人知道我应该使用什么版本吗?我还缺少依赖吗?我一直在阅读atlasian问答和各种google文档,我想我已经接近了,但是我不确定我还缺少什么.

Does anyone know what versions I should be using? Am I still missing dependencies? I've been reading through atlasian q/a's and various google documents and I think I'm close but I'm not sure what I'm still missing.

首先感谢所有人:)

推荐答案

实际问题在于,Spring的可传递依赖项覆盖了atlassian的可传递依赖项.解决此问题的方法是将依赖关系重新整理回jrjc所需的状态,而不是更新版本.

The actual issue lays in the fact that Spring's transitive dependencies override atlassian's transitive dependencies. The way to fix this is to wrangle the dependencies back to what the jrjc needs them to be, instead of the more up to date versions.

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.2.1-atlassian-2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpasyncclient</artifactId>
      <version>4.0-beta3-atlassian-1</version>
    </dependency>
  </dependencies>
</dependencyManagement>

注意:这些版本可能会在将来的版本中更改,但它们适用于JRJC核心版本3.0.0.您可以通过读取mvn dependency:tree的输出来查找,它会说类似:httpasyncclient:jar:4.0.2:compile - version managed from 4.0-beta3-atlassian-1,它使您知道maven正在使用httpsyncclient的4.0.2版本,因此您需要将其覆盖回4.0-beta3-atlassian-1

NOTE: These versions will probably change in future releases, but they work for JRJC core version 3.0.0. You can find out by reading the output of mvn dependency:tree, it will say something like: httpasyncclient:jar:4.0.2:compile - version managed from 4.0-beta3-atlassian-1 which lets you know that maven is using version 4.0.2 of httpsyncclient, so you need to override it back to 4.0-beta3-atlassian-1.

这篇关于无法创建AsynchronousJiraRestClientFactory(依赖项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆