springcloud项目使用gateway网关无法启动的问题
1、同时导入了web和gateway
报错原因:启动时默认使用了 spring-boot-starter-web 的内置容器,不支持非阻塞
问题解决:
1、 排除 web 内置容器
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- Maven整个生命周期内排除内置容器,排除内置容器导出成war包可以让外部容器运行spring-boot项目-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
2、使用 spring-webflux 模块
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>