[英]Maven - how to work with multiple versions of dependencies?
我有使用JIRA REST Java Client的项目。 它工作正常,直到我尝试将其与Spring Boot集成。 因为我无法从AsynchronousJiraRestClientFactory
调用createWithBasicHttpAuthentication
而没有错误。 我明白了:
ClassNotFoundException: org.apache.http.util.Args
所以我添加了HttpComponents Core blocking I/O(httpcore)
依赖到我的pom.xml
,但是之后我得到了
ClassNotFoundException: org.apache.http.nio.NHttpMessageParserFactory
我通过向pom.xml
添加HttpComponents Core non-blocking I/O(httpcore-nio)
解决了这个问题。 我现在有
NoSuchMethodError: org.apache.http.nio.client.HttpAsyncClient.start()V
我已经比较了dependency:tree
当项目具有spring boot parent时以及当它被注释掉时的dependency:tree
。 它告诉我,添加spring boot parent会更改我的依赖项的版本。 你可以在这里检查差异(左边没有弹簧靴,右边是弹簧靴)
似乎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肯定应该升级依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.