MavenShade插件 - 如何解决版本不匹配

问题描述 投票:0回答:0
在FOO中的某个地方,有以下代码

import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; ... CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslSocketFactory).build(); restTemplateBuilder = restTemplateBuilder.requestFactory(() -> new HttpComponentsClientHttpRequestFactory(httpClient));

我在Intellij中查看以下编译时错误:

Required type: HttpClient Provided type: CloseableHttpClient

是因为
HttpComponentsClientHttpRequestFactory
构建器的签名已从接受一个实例转变为接受

CloseableHttpClient

实例。
我说,我正在尝试使用Maven Shade插件来解决依赖项不匹配。这是
HttpClient

的相关部分
pom.xml
不幸的是,我仍然看到同样的错误。这是我第一次使用Maven Shade插件。您能帮我弄清楚我需要如何配置pom.xml解决问题?
fyi我正在使用java21.
	
事实证明,httpclient版本不匹配不是实际问题。由于httpclient 4和httpclient 5在不同的名称空间中,因此不需要阴影。

实际问题是由弹簧启动版本凸起引起的弹簧版本不匹配。这就是我需要解决的问题。 首先,我尝试在root Project的pom.xml中遮挡org.springframework(我们调用root project qux)。但是,我最终意识到这是不可能的,因为我在同一类Path上不能同时拥有Spring-Boot 2和Spring-boot 3。因此,任何一个Qux都会失败,因为Spring-boot 2在班级路径上,或者FOO会失败,因为Spring-Boot 3在Class Path上,我所有的阴影都是徒劳的。

最终,我意识到我必须在foo的pom.xml中执行阴影。由于我无法直接访问FOO的源代码,因此我通过Intellij创建了2个新模块:父母和bar。酒吧对FOO有一个依赖。我在Bar的XML中遮蔽了org.springframework。 在父pom.xml中,我在该部分中添加了bar和qux。现在,一切都像一个炭。

	

spring-boot pom.xml dependency-management maven-shade-plugin java-21
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.