为什么我无法映射Mono?

时间:2020-06-04 17:51:22

标签: scala project-reactor reactor spring-reactor

我有以下代码...

return Mono[...] = client.get()
    .uri(...)
    .retrieve()
    .bodyToMono(classOf[String])
    .map(convertToJson _)

工作正常,现在我想提供一个将内部集合作为CSV返回的功能,所以我尝试...

previous().map(
      response => response.getArrayOfThings.foreach(
        record => writer.println(record.toCsv)
      )
)

我希望作家会为集合中的每个项目被调用,但是,相反,我会遇到编译错误...

Error:(53, 26) no type parameters for method map: (x$1: java.util.function.Function[_ >: ..., _ <: R])reactor.core.publisher.Mono[R] exist so that it can be applied to arguments (java.util.function.Function[...,Unit])
 --- because ---
argument expression's type is not compatible with formal parameter type;
 found   : java.util.function.Function[...,Unit]
 required: java.util.function.Function[_ >: ..., _ <: ?R]
Note: ... <: Any, but Java-defined trait Function is invariant in type T.
You may wish to investigate a wildcard type such as `_ <: Any`. (SLS 3.2.10)

我是scala的新手,所以它很明显,但是我想念什么?

0 个答案:

没有答案