java - Maven - 如何使用多个版本的依赖项?

标签 java rest maven jira spring-boot

我有一个使用 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/

相关文章:

Java URL 在计时器上抓取股票报价

java - restTemplate 交换经常会导致 400 错误

java - WireMockServer 与 MockServerClient 的区别

maven - Sonatype Nexus可以使用maven的本地存储库吗

java - 也许您正在 JRE 而不是 JDK 上运行

java - 现实世界中的 Clojure 和 Java 互操作

java - JaxRs 客户端不执行 MessageBodyReader

java - Spring LDAP 空指针异常

java -xbootclass path 不再是受支持的选项

javascript - Sails JS - 添加文档并在响应中返回整个集合