From e55d7edb346fabf51b6168bdef34ce2d01dc375a Mon Sep 17 00:00:00 2001
From: Charles7c <charles7c@126.com>
Date: Fri, 9 Dec 2022 23:55:10 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E7=A7=BB=E9=99=A4?=
 =?UTF-8?q?=E5=86=85=E7=BD=AE=20Tomcat=20=E6=9C=8D=E5=8A=A1=E5=99=A8?=
 =?UTF-8?q?=EF=BC=8C=E9=9B=86=E6=88=90=20Undertow=20=E6=9C=8D=E5=8A=A1?=
 =?UTF-8?q?=E5=99=A8=EF=BC=88=E9=87=87=E7=94=A8=20Java=20=E5=BC=80?=
 =?UTF-8?q?=E5=8F=91=E7=9A=84=E7=81=B5=E6=B4=BB=E7=9A=84=E9=AB=98=E6=80=A7?=
 =?UTF-8?q?=E8=83=BD=20Web=20=E6=9C=8D=E5=8A=A1=E5=99=A8=EF=BC=8C=E6=8F=90?=
 =?UTF-8?q?=E4=BE=9B=E5=8C=85=E6=8B=AC=E9=98=BB=E5=A1=9E=E5=92=8C=E5=9F=BA?=
 =?UTF-8?q?=E4=BA=8E=20NIO=20=E7=9A=84=E9=9D=9E=E5=A0=B5=E5=A1=9E=E6=9C=BA?=
 =?UTF-8?q?=E5=88=B6=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 README.md                          | 11 ++++++-----
 pom.xml                            | 20 ++++++++++++++++++++
 src/main/resources/application.yml | 14 ++++++++++++++
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index ec00f984..46d7c7e5 100644
--- a/README.md
+++ b/README.md
@@ -5,14 +5,15 @@
 
 ### 简介
 
-ContiNew-Admin (incubating) 中后台管理框架,Continue New Admin,持续以最新流行技术栈构建。当前阶段采用的技术栈:Spring Boot 等。
+ContiNew-Admin (incubating) 中后台管理框架,Continue New Admin,持续以最新流行技术栈构建。当前阶段采用的技术栈:Spring Boot、Undertow 等。
 
 ### 技术栈
 
-| 名称                                                  | 版本    | 简介                                                         |
-| ----------------------------------------------------- | ------- | ------------------------------------------------------------ |
-| [Spring Boot](https://spring.io/projects/spring-boot) | 2.7.6   | 简化新 Spring 应用的初始搭建以及开发过程。                   |
-| [Lombok](https://projectlombok.org/)                  | 1.18.24 | 在 Java 开发过程中用注解的方式,简化了 JavaBean 的编写,避免了冗余和样板式代码,让编写的类更加简洁。 |
+| 名称                                                  | 版本         | 简介                                                         |
+| ----------------------------------------------------- | ------------ | ------------------------------------------------------------ |
+| [Spring Boot](https://spring.io/projects/spring-boot) | 2.7.6        | 简化新 Spring 应用的初始搭建以及开发过程。                   |
+| [Undertow](https://undertow.io/)                      | 2.2.20.Final | 采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制。 |
+| [Lombok](https://projectlombok.org/)                  | 1.18.24      | 在 Java 开发过程中用注解的方式,简化了 JavaBean 的编写,避免了冗余和样板式代码,让编写的类更加简洁。 |
 
 
 ### License
diff --git a/pom.xml b/pom.xml
index 53df4ff0..2c275ed8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,6 +33,26 @@
         <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>
+
+        <!-- Undertow 服务器(采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制) -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+            <!-- 移除 websocket 依赖,后续使用 websocket 可考虑由 Netty 提供。另可解决日志警告:UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used -->
+            <exclusions>
+                <exclusion>
+                    <groupId>io.undertow</groupId>
+                    <artifactId>undertow-websockets-jsr</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index e34adaf4..91538e7c 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -20,6 +20,20 @@ server:
   servlet:
     # 应用访问路径
     context-path: /
+  ## Undertow 服务器配置
+  undertow:
+    # HTTP POST 请求内容的大小上限(默认 -1 不限制)
+    max-http-post-size: -1
+    # 以下的配置会影响 buffer,这些 buffer 会用于服务器连接的 IO 操作,有点类似 Netty 的池化内存管理
+    # 每块 buffer的空间大小(越小的空间被利用越充分,不要设置太大,以免影响其他应用,合适即可)
+    buffer-size: 512
+    # 是否分配的直接内存(NIO 直接分配的堆外内存)
+    direct-buffers: true
+    threads:
+      # 设置 IO 线程数,它主要执行非阻塞的任务,它们会负责多个连接(默认每个 CPU 核心一个线程)
+      io: 8
+      # 阻塞任务线程池,当执行类似 Servlet 请求阻塞操作,Undertow 会从这个线程池中取得线程(它的值设置取决于系统的负载)
+      worker: 256
 
 --- ### Spring 配置
 spring: