@EnableWebFlux注解有什么用?

rak*_*hra 3 spring-boot spring-webflux

我只是不明白@EnableWebFlux 的真正需求是什么。因为,我能够编写一个简单的“helloworld”WebFlux REST API,并且能够向控制器发送请求,而无需使用该注释。

我已经看过文档,但我不清楚。

Dir*_*yne 6

如果您使用spring-boot-starter-webflux配置是通过ReactiveWebServerFactoryAutoConfiguration和自动完成的WebFluxAutoConfiguration,所以您不需要@EnableWebFlux

当你使用spring-webflux而不spring-boot需要添加@EnableWebFlux一个@Configuration类来导入Spring WebFlux配置WebFluxConfigurationSupport