网站首页 > 博客文章 正文
SpringBoot内置了三款web容器,分别是Tomcat、Jetty、undertow,默认的容器是Tomcat,三款web容器各有优点,总体来说差别不大,一般情况下,Tomcat就能满足我们的使用需求。
三款web容器的优点如下:
Tomcat:性能优异,相对来说运行过程中会加载一些比较重的组件,运行效率受一定影响;
Jettty: 轻量级应用,加载组件少,适合小项目,性能不高;
undertow: 性能比Tomcat有优势,使用的人群小;
一、默认Tomcat容器
在Springboot项目的pom配置文件中引入了spring-boot-starter-web中,包含了对Tomcat的引用。
启动Springboot项目后能看到Tomcat容器的启动日志:
二、修改为Jetty容器
首先需要在spring-boot-starter-web中排除对Tomcat的引用。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
然后引入jetty的starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
刷新pom文件,下载相关的jar包,然后启动SpringBoot项目。
这时能看到启动日志中,web容器已经变成了Jetty。
三、修改为undertow容器
首先需要在spring-boot-starter-web中排除对Tomcat的引用。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
然后引入undertow的starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
刷新pom文件,下载相关的jar包,然后启动SpringBoot项目。
这时能看到启动日志中,web容器已经变成了undertow。
猜你喜欢
- 2024-10-29 jfinal vue ElementUI OA HRM的前后端分离CRM系统源码免费分享
- 2024-10-29 如何项目性能优化?压力测试,数据分析,代码实战
- 2024-10-29 Spring Boot 3 使用 Java 17 和 Jakarta EE 9,并支持GraalVM 的原生 Java
- 2024-10-29 走进Spring Boot源码学习之路和浅谈入门
- 2024-10-29 7 种提升 Spring Boot 吞吐量神技
- 2024-10-29 教你Spring Boot 2.3 优雅关闭的新姿势
- 2024-10-29 拥抱Kubernetes,再见了Spring Cloud
- 2024-10-29 美团动态线程池实践思路,开源了(美团 线程池)
- 2024-10-29 Spring Boot性能优化:提高响应速度的秘密
- 2024-10-29 Java 9 和Spring Boot 2.0纷纷宣布支持的HTTP/2到底是什么?
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)