'Mono.and()' 无法使用提供的参数调用

'Mono.and()' cannot be called with the supplied parameters

我正在尝试 运行 位于 here 的示例项目。但是,我看到

Error:(38, 22) Kotlin: None of the following functions can be called with the arguments supplied: public final fun and(p0: ((Subscriber<in Any!>!) -> Unit)!): Mono<Void!>! defined in reactor.core.publisher.Mono public final fun and(p0: Publisher<*>!): Mono<Void!>! defined in reactor.core.publisher.Mono

ApiHandler.kt中class在buildResponse函数中:

internal class ApiHandler(val geoLocationService: GeoLocationService, val sunriseSunsetService: SunriseSunsetService,
                      val errorHandler: ErrorHandler) {

    private companion object {
        const val ADDRESS = "address"
    }

    internal fun getLocation(request: ServerRequest) =
        request.pathVariable(ADDRESS).toMono()
                .transform(this::buildResponse)
                .transform(this::serverResponse)
                .onErrorResume(errorHandler::throwableError)!!

    internal fun postLocation(request: ServerRequest) =
        request.extract<LocationRequest>()
                .map(LocationRequest::address)
                .transform(this::buildResponse)
                .transform(this::serverResponse)
                .onErrorResume(errorHandler::throwableError)!!

    internal fun buildResponse(address: Mono<String>) =
        address.transform(geoLocationService::fromAddress)
                .and(this::sunriseSunset, ::LocationResponse)

    internal fun sunriseSunset(geographicCoordinates: GeographicCoordinates) =
        geographicCoordinates.toMono().transform(sunriseSunsetService::fromGeographicCoordinates)

    internal fun serverResponse(locationResponseMono: Mono<LocationResponse>): Mono<ServerResponse> =
        locationResponseMono.flatMap { ok() withBody it }
}

我猜 Spring API 自从编写这段代码以来已经发生了变化,但我不知道要将 .and(...) 更改为什么。

我认为这与 3.1.0 中的 Reactor Core API 变化有关。

Mono.and() 不再是 returns 元组的运算符,但它现在只关心完成信号 (Mono<Void>)。您应该按照 the Reactor release notes.

中的建议,将 and() 运算符替换为 zipzipWith 运算符