SpringWeb Flux入门

新建项目,加入依赖:


org.springframework.boot
spring-boot-starter-webflux


org.springframework.boot
spring-boot-starter-test
test


io.projectreactor
reactor-test
test

SpringBoot版本选择2.7.9。

增加Controller:

@RestController
@RequestMapping("/flux")
public class MyController {

@RequestMapping("/hello")
public Mono hello() {
return Mono.just("Flux");
}
}

访问 http://localhost:8080/flux/hello ,看到Flux。查看控制台看到:

 

 

看到Spring Flux 使用Netty作为容器。

posted @ 2023-05-06 14:19  shigp1  阅读(296)  评论(0)    收藏  举报