【发布时间】:2021-09-15 10:00:46
【问题描述】:
在 pom.xml 中从 Spring Boot 版本 2.3.5.RELEASE 升级到 2.4.0 后,无法再导入类 ProxyProvider (import reactor.netty.tcp.ProxyProvider;)。请注意,即使使用更高版本的 Spring Boot(尝试了 2.5.0 和 2.5.2)它也不起作用。
通过检查 Maven 依赖项,我注意到:
- 在 2.3.5.RELEASE 版本中,该类取自
io.projectreactor.netty:reactor-netty:0.9.12.RELEASE - 在 2.4.0 版本中,该类取自
io.projectreactor.netty:reactor-netty-http:1.0.1
我可以通过检查导入的类 reactor.netty.http.client.HttpClient 的来源来找到有关 IntelliJ 的信息,尽管来自上述两个不同的库,但它适用于两个版本。
您知道如何解决从 Spring Boot 2.4.0 开始的编译问题吗?
请注意,我在 Spring Boot 的问题跟踪器中发现了相同的问题,但不幸的是它已关闭,没有给出任何解释:https://github.com/spring-projects/spring-boot/issues/24414。
作为进一步的信息,这些是 2.3.5.RELEASE 情况下的所有 Netty 依赖项:
这些当 Spring Boot 版本是 2.4.0 时:
还请注意,在 pom.xml 中,我在两种情况下都导入了 2.3.5 版的依赖项 azure-keyvault-secrets-spring-boot-starter(但即使使用已移至该库的最新版本,它也会出现相同的问题https://mvnrepository.com/artifact/com.azure.spring/azure-spring-boot-starter-keyvault-secrets/3.6.0) :
<!-- Azure KeyVault access (password safe) -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-secrets-spring-boot-starter</artifactId>
<version>${azure.version}</version>
<scope>runtime</scope>
</dependency>
这是使用 ProxyProvider 类的代码:
HttpClient httpClient = HttpClient.create()
.tcpConfiguration(tcpClient -> (sslContext != null
? tcpClient.secure(sslProviderBuilder -> sslProviderBuilder.sslContext(sslContext))
: tcpClient)
.proxy(proxy -> proxy
.type(ProxyProvider.Proxy.HTTP)
.host(host)
.port(port))
);
【问题讨论】:
标签: java spring-boot maven netty reactor-netty