切换内置web服务器
springboot的web环境中默认使用tomcat作为内置服务器,其实springboot提供了4中内置服务器供我们使用。我们可以方便切换。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
在运行的时候会显示Tomcat日志信息
在哪查看内置的web服务
如何修改内置服务器
我们只要在pom.xml中退出默认tomCat服务器,导入其他依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 排除TomCat依赖-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 引入jetty依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
控制台中有jetty日志信息。没有可以刷新一下maven
Netty服务器
<!--导入Netty依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
undertow 服务器
<!-- 使用undertow 作为web服务器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>