我正在尝试使用带有reactor和spring的java将
Mono<Part>
转换为Mono<InputStream>
。
我有一个可以正常编译和工作的代码,但它会生成 Intellij 错误。
代码:
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.codec.multipart.Part;
import reactor.core.publisher.Mono;
import java.io.InputStream;
public Mono<InputStream> loadFile(Mono<Part> fileMono) {
return DataBufferUtils.join(fileMono.flatMapMany(Part::content))
.map(DataBuffer::asInputStream);
}
错误:
Required type: Publisher
Provided: Flux <org.springframework.core.io.buffer.DataBuffer>
no instance(s) of type variable(s) R exist so that Flux<R> conforms to Publisher<? extends DataBuffer>
作为
Flux<T> implements CorePublisher<T>
和CorePublisher<T> extends Publisher<T>
,我不明白这个错误。
此外,我的一些同事有错误,而其他人则没有。
这很奇怪。
我尝试通过 gradle 删除并重新导入库依赖项,并执行所有 7 个 intellij 步骤来调试项目,包括清除缓存和重新索引应用程序。
可能出了什么问题?
嗯,显然 Intellij 中的 Kotlin 插件有错误。
https://youtrack.jetbrains.com/issue/KTIJ-16925
建议的解决方案是: