使用webclient时出现以下异常
Failed to instantiate [org.springframework.web.reactive.function.client.WebClient]: Factory method 'webClient' threw exception; nested exception is java.lang.NoSuchMethodError: reactor.netty.http.client.HttpClient.option(Lio/netty/channel/ChannelOption;Ljava/lang/Object;)Lreactor/netty/transport/Transport;
相关jar
这是一个基于蚂蚁的spring项目。我没有得到任何编译错误。
这是我创建webclient的代码
WebClient webClient(ReactiveClientRegistrationRepository clientRegistrations ) {
HttpClient httpClient = HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
.responseTimeout(Duration.ofMillis(5000))
.doOnConnected(conn ->
conn.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS))
.addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS)));
ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
InMemoryReactiveOAuth2AuthorizedClientService authorisedClient=new InMemoryReactiveOAuth2AuthorizedClientService(clientRegistrations);
ServerOAuth2AuthorizedClientExchangeFilterFunction oauth=new ServerOAuth2AuthorizedClientExchangeFilterFunction(new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager(clientRegistrations,authorisedClient));
oauth.setDefaultClientRegistrationId("id");
return WebClient.builder().baseUrl("sample URL")
.clientConnector(connector)
.filter(oauth)
.build();
}
id和sample url是我替换的值。看起来这是一些jar问题,但是我已经添加了几乎所有我在研究这个错误时发现的jar。
谢谢
暂无答案!
目前还没有任何答案,快来回答吧!