一, 快速搭建webflux项目
1, 引入相关依赖
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.6.5</version><relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<!-- 解决mac系统Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider异常 -->
<dependency><groupId>io.netty</groupId><artifactId>netty-all</artifactId><version>4.1.72.Final</version>
</dependency>
启动类还是原来的@SpringBootApplication.
如果想要跳转指定静态页面,需要注入RouterFunction
@Value("classpath:pages/index.html")
private Resource indexHtml;
@Bean