新建项目,加入依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
SpringBoot版本选择2.7.9。
增加Controller:
@RestController
@RequestMapping("/flux")
public class MyController {
@RequestMapping("/hello")
public Mono<String> hello() {
return Mono.just("Flux");
}
}
访问http://localhost:8080/flux/hello,看到Flux。查看控制台看到:
看到Spring Flux 使用Netty作为容器。
标签:入门,spring,SpringWeb,boot,public,Flux,test,hello From: https://www.cnblogs.com/shigongp/p/17377140.html