DataBufferLimitException:超出了最大限制以缓冲webflux错误 [英] DataBufferLimitException: Exceeded limit on max bytes to buffer webflux error
本文介绍了DataBufferLimitException:超出了最大限制以缓冲webflux错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在发送文件时,我收到一个字节数组.我总是对webflux接收数组有问题.引发的错误如下:
While sending a file I receive an array of bytes. I always have a problem with webflux to receive an array. the error thrown as below :
org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144
at org.springframework.core.io.buffer.LimitedDataBufferList.raiseLimitException(LimitedDataBufferList.java:101)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException
您现在如何在webflux中解决该问题?
Do you now how to resolve that in webflux ?
推荐答案
这个为我工作的人
-
在您的配置类或主Springbootapplication类中创建一个Bean
Create a bean in your one of the configuration class or the main Springbootapplication class
@Bean
public WebClient getWebClientBuilder(){
return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
.codecs(configurer -> configurer
.defaultCodecs()
.maxInMemorySize(16 * 1024 * 1024))
.build())
.build();
}
下一步转到您要在其中使用网络客户端的所需课程
Next go to your desired class where you want to use the webclient
@RestController / @Bean/ @Service
public class PaySharpGatewayController {
@Autowired
WebClient webClient;
public void test(){
String out = webClient
.get()
.uri("end point of an API")
.retrieve()
.bodyToMono(String.class)
.block();
sysout(out)
}
这篇关于DataBufferLimitException:超出了最大限制以缓冲webflux错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文