首页 > 解决方案 > 如何在 Spring webflux 中处理 IOException?

问题描述

我试图从我的 Mono 中检索 byte[],但使用 getBytes() 方法显示未处理的 IOException。如何在我的反应式代码中处理它?

我的服务层

public HttpStatus excel(Mono<MultipartFile> filePartMono) {
        Excel t = new Excel();
        t.setExcel(filePartMono.map(filepart-> {
            try {
                return filepart.getBytes();
            } catch (IOException e) {
                System.out.println(e);
            }
            return new **byte[];** //doing this here it shows array initializer expected what does it mean 
        }));
    excelRepository.save(t);
        return HttpStatus.ACCEPTED>; 

标签: exceptionreactive-programmingspring-webfluxproject-reactor

解决方案


推荐阅读