我正在尝试在非spring应用程序的DefaultExchangeStrategiesBuilder.DEFAULT_EXCHANGE_STRATEGIES应用程序中使用 WebClient wc = WebClient.create();,但它看起来像是返回null。
causing error:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.web.reactive.function.client.DefaultExchangeStrategiesBuilder
at org.springframework.web.reactive.function.client.ExchangeStrategies.withDefaults(ExchangeStrategies.java:67)
at org.springframework.web.reactive.function.client.DefaultWebClientBuilder.initExchangeStrategies(DefaultWebClientBuilder.java:302)
at org.springframework.web.reactive.function.client.DefaultWebClientBuilder.build(DefaultWebClientBuilder.java:269)
at org.springframework.web.reactive.function.client.WebClient.create(WebClient.java:144)我在我的POM中增加了以下内容:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.6.5</version>
</dependency>发布于 2022-04-15 19:13:36
如果您的应用程序不是Spring应用程序,并且不应用Spring的依赖项管理,则不应该使用Spring的启动程序。
相反,您应该直接使用Spring的spring-webflux依赖项,以及您选择的客户端库,比如反应堆Netty,Jetty客户端,Apache HttpComponents.
还应确保将应用于您的项目,以避免应用程序中出现不兼容的混合版本:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>...</version>
<type>pom</type>
</dependency>https://stackoverflow.com/questions/71786601
复制相似问题