Spring Reactive xml payload exception java.lang.IllegalStateException: Failed to resolve argument 0 of type 'reactor.core.publisher.Mono'

前端 未结 3 1067
情深已故
情深已故 2021-01-28 23:19

I have a spring boot application. trying to send xml payload through postman to a Post request. I get the following exception

java.lang.IllegalS         


        
相关标签:
3条回答
  • 2021-01-28 23:58

    As pointed out by KOrest, Jaxb2XmlDecoder did not implement decodeToMono, but it is now fixed via SPR-16759. So just upgrading to Spring Framework 5.0.6+ / Spring Boot 2.0.2+ should avoid the reported exception.

    Side note: like by Brian Clozel, I am not sure of what you try to achieve and you probably should not call subscribe manually but instead return a transformation of the input. doOnNext can be used if you want to print the output without triggering the demand artificially.

    0 讨论(0)
  • 2021-01-29 00:03

    Not sure why but as I can see it uses Jaxb2XmlDecoder for decoding XML payload and decodeToMono method is not implemented there.

    To fix this you can use Flux<Sir> type as a requestBody

    0 讨论(0)
  • 2021-01-29 00:08

    Could you explain what are you trying to achieve in your Controller?

    This error probably comes from the fact that you're calling subscribe in your controller method, effectively consuming the incoming Flux and returning at the same time.

    As a general rule, you shouldn't subscribe to Publishers within your Controllers.

    0 讨论(0)
提交回复
热议问题