基于 Apache Tomcat 11.0.27 上游源码

GLServer

面向 Java 与 Spring Boot 的高性能嵌入式 Servlet 容器。一行依赖替换默认 Web 容器,安全默认。

v11.0.27-20261024 Spring Boot 4.1.0 JDK 22+ 5 个模块

产品亮点

保留上游成熟内核,同时把国产化与安全默认做到位。

一行依赖,无缝替换

引入 spring-boot-starter-glserver,无需改动任何业务代码,即可替换 Spring Boot 4 默认 Web 容器。

Spring Boot 4 原生集成

实现 Spring Boot 4 的 WebServer 与 ConfigurableServletWebServerFactory 接口,server.port、server.address 等标准配置直接生效。

安全默认

不启用 AJP 连接器,不内置管理后台,不输出服务端版本头,降低默认攻击面。

模块化

核心容器、EL 表达式、WebSocket 独立成模块,按需引入,精简依赖。

多实例友好

工作目录使用带随机后缀的系统临时目录,不污染项目目录,同机多服务并存不冲突。

上游可追溯

基于 Apache Tomcat 上游源码自动生成,版本与变更清晰可追溯,便于持续跟进上游修复。

快速开始

四步接入一个 Spring Boot 4 应用。

1

添加依赖

引入 GLServer Starter,并从 spring-boot-starter-webmvc 中排除官方默认容器。

pom.xml
<dependency>
  <groupId>org.glaer.glserver</groupId>
  <artifactId>spring-boot-starter-glserver</artifactId>
  <version>11.0.27-20261024</version>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-webmvc</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat-runtime</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-tomcat</artifactId>
    </exclusion>
  </exclusions>
</dependency>
// build.gradle
dependencies {
  implementation 'org.glaer.glserver:spring-boot-starter-glserver:11.0.27-20261024'
  implementation('org.springframework.boot:spring-boot-starter-webmvc') {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat-runtime'
    exclude group: 'org.springframework.boot', module: 'spring-boot-tomcat'
  }
}
2

启动应用

mvn spring-boot:run

无需额外代码,自动配置会注册 GLServer 容器。

3

验证

curl http://localhost:8080/

默认监听 8080。

4

配置端口

标准 Spring Boot 配置直接生效,例如改用 9090。

# application.properties
server.port=9090

模块构成

GLServer 由五个 Maven 模块组成,核心能力可按需组合。

模块 说明 引入方式
glserver-embed-core 核心 Servlet 容器(HTTP/1.1、HTTP/2) 必需
glserver-embed-el Jakarta EL 表达式引擎 由 Starter 传递引入
glserver-embed-websocket WebSocket 支持 可选
spring-boot-starter-glserver Spring Boot 4 自动配置与容器适配 必需
glserver-sample 示例应用与集成测试 否

环境要求

JDK 22+(字节码目标 22)
Spring Boot 4.1.0
Maven 3.9+ 或 Gradle

安全默认

默认配置即收敛攻击面,减少上线前的安全整改成本。

无 AJP

不创建 AJP 连接器,避免跨协议攻击面。

无管理后台

不打包任何 Web 管理应用。

无版本头

默认不返回 Server 响应头,减少信息泄露。

临时工作目录

工作文件写入系统临时目录,退出后清理。

配置

GLServer 复用 Spring Boot 标准配置。当前版本已支持以下属性:

server.port

监听端口,例如 9090;设为 0 表示随机端口。

server.address

绑定地址;留空表示绑定所有网卡。

获取 GLServer

GLServer 发布在 Maven Central,直接通过构建工具引入。

org.glaer.glserver:spring-boot-starter-glserver:11.0.27-20261024

坐标:org.glaer.glserver:spring-boot-starter-glserver:11.0.27-20261024