0
点赞
收藏
分享

微信扫一扫

Android的Compose

凌得涂 02-20 08:30 阅读 5

目录

1.说明

2.Undertow概述

3.springboot集成undertow


1.说明

作为springboot开发者,使用最多的就是Tomcat,这是springboot默认的容器技术,而且是内嵌式的Tomcat,springboot作为目前最火的Java Web框架,可以说容器也起到了绝对的优势。对于一个应用,我们也只需要将应用打包成一个jar包,以java -jar直接运行,而无需再打成war包的形式外搭tomcat服务器的方式运行应用。但是也会考虑使用Undertow容器去替代Tomcat。

2.Undertow概述

Undertow作为SpringBoot默认集成的三大容器之一(Tomcat、Jetty、Undertow);首先它是Red Hat公司旗下的开源产品, 由Java语言开发,是一款灵活的高性能Web服务器;不仅支持阻塞IO还支持非阻塞IO。由于Undertow通过java语言开发,即在java项目中使用可直接嵌入。而且,Undertow完全支持Servlet和Web Socket,在高并发情况下表现非常出色,总之,Undertow在性能和内存使用方面都优于Jetty、Tomcat。

所以这就是为何业界内很多springboot开发者放弃Tomcat,选择Undertow。

3.springboot集成undertow

由于springboot优先默认内嵌的是tomcat,所以当你在引入Undertow容器时,你就需要先排除掉Tomcat,也就是它
spring-boot-starter-tomcat,因此你需要找到spring-boot-starter-web这个starter,把Tomcat去掉,然后再引入undertow的依赖,然后直接启动项目即可。

<!--web依赖-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <!--排除spring-boot-starter-tomcat-->
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<!-- 添加Undertow容器 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

参照:
 Spring Boot:如何配置Undertow容器?不会我教你 | 超级详细 - 简书

举报

相关推荐

0 条评论