面向 Java 与 Spring Boot 的高性能嵌入式 Servlet 容器。一行依赖替换默认 Web 容器,安全默认。
保留上游成熟内核,同时把国产化与安全默认做到位。
引入 spring-boot-starter-glserver,无需改动任何业务代码,即可替换 Spring Boot 4 默认 Web 容器。
实现 Spring Boot 4 的 WebServer 与 ConfigurableServletWebServerFactory 接口,server.port、server.address 等标准配置直接生效。
不启用 AJP 连接器,不内置管理后台,不输出服务端版本头,降低默认攻击面。
核心容器、EL 表达式、WebSocket 独立成模块,按需引入,精简依赖。
工作目录使用带随机后缀的系统临时目录,不污染项目目录,同机多服务并存不冲突。
基于 Apache Tomcat 上游源码自动生成,版本与变更清晰可追溯,便于持续跟进上游修复。
四步接入一个 Spring Boot 4 应用。
引入 GLServer Starter,并从 spring-boot-starter-webmvc 中排除官方默认容器。
<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'
}
}
mvn spring-boot:run
无需额外代码,自动配置会注册 GLServer 容器。
curl http://localhost:8080/
默认监听 8080。
标准 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.0Maven 3.9+ 或 Gradle默认配置即收敛攻击面,减少上线前的安全整改成本。
不创建 AJP 连接器,避免跨协议攻击面。
不打包任何 Web 管理应用。
默认不返回 Server 响应头,减少信息泄露。
工作文件写入系统临时目录,退出后清理。
GLServer 复用 Spring Boot 标准配置。当前版本已支持以下属性:
server.port
监听端口,例如 9090;设为 0 表示随机端口。
server.address
绑定地址;留空表示绑定所有网卡。
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