我有使用JIRA REST Java客户端的项目。在我尝试将其与Spring Boot集成之前,它一直运行良好。从那以后,我将无法从createWithBasicHttpAuthentication
正确地调用AsynchronousJiraRestClientFactory
。我得到:
ClassNotFoundException: org.apache.http.util.Args
所以我在
HttpComponents Core blocking I/O(httpcore)
中添加了pom.xml
依赖项,但之后我得到了ClassNotFoundException: org.apache.http.nio.NHttpMessageParserFactory
我通过将
HttpComponents Core non-blocking I/O(httpcore-nio)
添加到pom.xml
来解决。我现在有NoSuchMethodError: org.apache.http.nio.client.HttpAsyncClient.start()V
我已经比较了
dependency:tree
在项目具有spring boot父项时和注释掉时的情况。它向我展示了添加spring boot parent会更改依赖项的版本。您可以检查diff here (左侧不带弹簧靴,右侧带弹簧靴)看来JIRA REST Java Client需要某些依赖项的较旧版本。
如何解决此问题?
pom.xml
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RELEASE</version>
</parent>
...
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
<version>4.3</version>
</dependency>
</dependencies>
...
最佳答案
我可以通过覆盖pom.xml中的这些属性来修复Spring Boot应用程序中的运行时
<properties>
<httpasyncclient.version>4.0-beta3-atlassian-1</httpasyncclient.version>
<httpclient.version>4.2.1-atlassian-2</httpclient.version>
</properties>
请注意,如果您决定在项目中使用http-client和/或httpassync客户端(例如,使用RestTemplate),可能还会有其他问题。
Atlassian应该绝对升级依赖项。
关于java - Maven-如何使用多个版本的依赖项?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26521932/