我有一个使用 JIRA REST Java 客户端的项目。在我尝试将它与 Spring Boot 集成之前,它运行良好。因为我无法从 AsynchronousJiraRestClientFactory
调用 createWithBasicHttpAuthentication
而不会出错。我得到:
ClassNotFoundException: org.apache.http.util.Args
所以我向我的 pom.xml
添加了 HttpComponents Core blocking I/O(httpcore)
依赖项,但之后我得到了
ClassNotFoundException: org.apache.http.nio.NHttpMessageParserFactory
我通过将 HttpComponents Core 非阻塞 I/O(httpcore-nio)
添加到 pom.xml
来解决这个问题。现在我有
NoSuchMethodError: org.apache.http.nio.client.HttpAsyncClient.start()V
我比较了 dependency:tree
当项目有 spring boot parent 和当它被注释掉时。它向我展示了添加 spring boot parent 会更改我的依赖项的版本。你可以检查 diff here (左边没有 Spring Boot ,右边有 Spring Boot )
似乎 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/