From e64553e6205ca3473a656f60448304bf4c18ddca Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 22 Jul 2025 22:40:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(web):=20=E6=8B=86=E5=88=86=20default-w?= =?UTF-8?q?eb.yml=20=E4=B8=BA=20default-response.yml=20=E5=92=8C=20default?= =?UTF-8?q?-server.yml=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GlobalResponseAutoConfiguration.java | 2 +- .../server/UndertowAutoConfiguration.java | 3 +++ .../{default-web.yml => default-response.yml} | 17 ----------------- .../src/main/resources/default-server.yml | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 18 deletions(-) rename continew-starter-web/src/main/resources/{default-web.yml => default-response.yml} (54%) create mode 100644 continew-starter-web/src/main/resources/default-server.yml diff --git a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java index 8d0a78a2..90803037 100644 --- a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java +++ b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java @@ -54,7 +54,7 @@ import java.util.concurrent.CopyOnWriteArrayList; */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(GlobalResponseProperties.class) -@PropertySource(value = "classpath:default-web.yml", factory = GeneralPropertySourceFactory.class) +@PropertySource(value = "classpath:default-response.yml", factory = GeneralPropertySourceFactory.class) public class GlobalResponseAutoConfiguration { private static final Logger log = LoggerFactory.getLogger(GlobalResponseAutoConfiguration.class); diff --git a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/server/UndertowAutoConfiguration.java b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/server/UndertowAutoConfiguration.java index e44a6025..d64f6609 100644 --- a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/server/UndertowAutoConfiguration.java +++ b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/server/UndertowAutoConfiguration.java @@ -30,8 +30,10 @@ import org.springframework.context.annotation.Bean; import io.undertow.Undertow; import io.undertow.server.handlers.DisallowedMethodsHandler; import io.undertow.util.HttpString; +import org.springframework.context.annotation.PropertySource; import top.continew.starter.core.constant.PropertiesConstants; import top.continew.starter.core.util.CollUtils; +import top.continew.starter.core.util.GeneralPropertySourceFactory; /** * Undertow 自动配置 @@ -44,6 +46,7 @@ import top.continew.starter.core.util.CollUtils; @ConditionalOnWebApplication @ConditionalOnClass(Undertow.class) @EnableConfigurationProperties(ServerExtensionProperties.class) +@PropertySource(value = "classpath:default-server.yml", factory = GeneralPropertySourceFactory.class) @ConditionalOnProperty(prefix = "server.extension", name = PropertiesConstants.ENABLED, havingValue = "true") public class UndertowAutoConfiguration { diff --git a/continew-starter-web/src/main/resources/default-web.yml b/continew-starter-web/src/main/resources/default-response.yml similarity index 54% rename from continew-starter-web/src/main/resources/default-web.yml rename to continew-starter-web/src/main/resources/default-response.yml index 4d4b3cb6..49d0a71f 100644 --- a/continew-starter-web/src/main/resources/default-web.yml +++ b/continew-starter-web/src/main/resources/default-response.yml @@ -23,20 +23,3 @@ continew-starter.web.response: - io.swagger.** - org.springdoc.** - org.springframework.boot.actuate.* - ---- ### 服务器配置 -server: - ## 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 \ No newline at end of file diff --git a/continew-starter-web/src/main/resources/default-server.yml b/continew-starter-web/src/main/resources/default-server.yml new file mode 100644 index 00000000..f04aaa27 --- /dev/null +++ b/continew-starter-web/src/main/resources/default-server.yml @@ -0,0 +1,16 @@ +--- ### 服务器配置 +server: + ## 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 \ No newline at end of file