Closed sangtraceur closed 7 years ago
Can you please provide a complete, yet minimal, sample that illustrates the problem?
Please see a repo with the example
Hi @sangtraceur
I'm not sure this was intentional, but adding spring-boot-starter-hateoas
as a dependency also brings spring-boot-starter-web
transitively (at least for now, we're in the process of revisiting a few of those choices). Having both Spring MVC and Spring WebFlux on the classpath, Spring Boot assumes you want to use Spring MVC and you've brought WebFlux in your classpath to use its new HTTP client WebClient
. Also, HATEAOS does not support (yet) WebFlux. Now this may have been a deliberate choice, but I just wanted to point that out.
Spring MVC now supports reactive endpoints as well. You won't have the full reactive experience since the Servlet support won't be fully non-blocking, but you can express your endpoints using Flux
and Mono
and still get some benefits out of it.
In order to do that, Spring MVC switches to async mode, just as if you were using one of the async return types like ResponseBodyEmitter
or SseEmitter
. In a nutshell, doing so will ask Spring MVC to take full control of the servlet response lifecycle (i.e. you should never write to it "manually").
In your project, injecting Writer responseWriter
indeed asks for the Servlet response writer, which is resolved by ServletResponseMethodArgumentResolver
. This class calls response.getWriter()
and this has been done already by Sprinb MVC; this is why you're getting that error.
Removing that method argument solves the issue completely; in fact, getting the Servlet response or any related item in a controller handler should always be the last choice, since you're asking for more control (and more responsibilities).
Hello! Id like to ask if I'am making something wrong during adding reactive support to my application: My controller is:
I'am facing an error during invocation:
As you see request is handled by webmvc, not webflux. Maby I should configure something more to make it work or it is really a bug?
My gradle dependencies: