If for any reason, it's still necessary to keep `s...
# spring
l
If for any reason, it's still necessary to keep
spring-boot-starter-web
, is it possible to use
Coroutines
by adding
spring-boot-starter-webflux
? will it work properly to have a
Flow
controller function for data stream?
not kotlin but kotlin colored 1
r
I think you can't use both -web and -webflux starters at the same time.
l
you can... but not all Reactive components are available/started since the application type is still
servlet
. that's my question's point
j
If we're talking boot, there's a property you can set that will flip things to reactive mode. The reason this is guarded by a property is so that non-reactive users can put webflux on the classpath for the purposes of WebClient and still have their webserver be plain old requet-per-thread
Actually it's not really a property. its this: https://docs.spring.io/spring-boot/docs/current/reference/html/web.html#web.reactive.webflux
Adding both
spring-boot-starter-web
and
spring-boot-starter-webflux
modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux. This behavior has been chosen because many Spring developers add
spring-boot-starter-webflux
to their Spring MVC application to use the reactive
WebClient
. You can still enforce your choice by setting the chosen application type to
SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)
l
I think I know the answer... but the point was if it may be still possible to use Coroutines while the Spring application is set to mvc/servlet... but having
webflux
also in the classpath.
j
sure, you'll just need to wrap every entry point in a runBlocking