【发布时间】:2021-02-04 20:54:24
【问题描述】:
我正在尝试使用 spring webflux 以反应方式从类路径中读取文件。我能够读取文件。但我无法解析为 Foo 对象。
我正在尝试以下方式,但不确定如何转换为 FOO 类。
public Flux<Object> readFile() {
Flux<DataBuffer> readFile1 = DataBufferUtils.read("classpath:test.json", new DefaultDataBufferFactory(), 4096);
return new Jackson2JsonDecoder().decode(readFile1,
ResolvableType.forType(List.class,Foo.class), null, Collections.emptyMap());
}
帮助表示赞赏。
【问题讨论】:
-
您可以将通量转换为单声道,然后是平面映射,然后在字节流上使用对象映射器。
标签: java spring spring-webflux readfile reactive