您现在的位置是:首页 > 文章详情

🎉smart-servlet v2.2 发布,不足 1MB 的国产 Servlet 容器

日期:2024-09-02点击:158

1、smart-servlet 简介

smart-servlet 是一个基于 Jakarta Servlet 6.0 的轻量级 Servlet 容器,适用于 Java 17+ 环境。

产品特色

  • 国产血统:全球首款全栈核心技术自研的国产 Servlet 容器。

  • 性能优越:搭载最新版通信微内核(smart-socket)和 http 服务模块 (smart-http)。

  • 安全可靠:严格遵循协议规范;支持加密传输方式。

  • 极致轻量:发行包不足 1 MB

  • 简洁易用:支持 War 包、springboot、maven-plugin 等多种运行模式,使用体验 100% 兼容 Tomcat。

目标用户

  • 有着信创需求的企业用户。

  • 对服务并发能力要求高的企业用户。

  • 想要研究 servlet 技术的个人开发者。

2、 版本更新

这个版本 smart-servlet 实现了 Servlet 安全相关的全部规范,使得 Servlet 规范的实现完整度提升至 98.3%,现在仅剩不足 30 个测试用例有待通过。

另外,随着 smart-http v1.6.0 版本实现了 multipart 规范。smart-servlet 此次完全脱离了对于 commons-fileupload 的依赖,采用 smart-http 提供的文件上传能力。

其他优化:

  • 优化 fragment 相关规范的实现。

  • 优化 ServletRequestListener 规范实现。

  • 优化 DispatcherType.INCLUDE 实现规范。

  • 优化 welcome file 实现规范。

  • 实现 security 相关规范。

  • 集成 smart-http 实现的 multipart 规范,移除 commons-fileupload 三方依赖

TCK 报告:

version Tests Errors Success Rate Time
v2.0 1716 199 88.4% 2024-07-28
v2.1 1718 95 94.5% 2024-08-11
v2.2 1716 29 98.3% 2024-08-31

、快速上手

我们提供了三种方式启用 smart-servlet,您可根据实际情况选择其中适用的一种。

方式一:maven 插件

这是一种类似:tomcat-maven-plugin 的使用方式,通常应用于 Java Web 工程的本地开发环境。集成该插件只需在 pom.xml 中加入以下代码,便可以在 IDE 中启动 servlet 服务。

 <build> <plugins> <plugin> <groupId>tech.smartboot.servlet</groupId> <artifactId>smart-servlet-maven-plugin</artifactId> <version>{最新版}</version> <configuration> <port>8080</port> <path>/portal</path> </configuration> </plugin> </plugins> </build>

插件的版本建议采用最新版本,另外主要的配置项包括:

  • port:servlet 服务启动的监听端口

  • path:Servlet 容器上下文路径,即 ContextPath,通常以 / 表示。当然也支持自定义,但必须以 / 开头 完成配置后在控制台输入:mvn package smart-servlet:run 即可。

方式二:smart-servlet-spring-boot-starter

用过 springboot 的 spring-boot-starter-tomcat 或者 spring-boot-starter-undertow 的朋友应该对此不陌生。

smart-servlet-spring-boot-starter 本质上就是 smart-servlet 对 spring-boot-starter-web 的另一种适配。

只需按照以下方式调整 springboot 工程中 pom.xml 文件的配置,便可将 springboot 的默认 Servlet 容器替换成 smart-servlet。

 <dependencys> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <!-- Exclude the Tomcat dependency --> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <!-- Use smart-servlet instead --> <dependency> <groupId>tech.smartboot.servlet</groupId> <artifactId>smart-servlet-spring-boot-starter</artifactId> <version>{最新版}</version> </dependency> </dependencys>

方式三:发行包

发行包适用于 War 包的部署方式,也是生产环境中常用的一种形式。

下载地址:https://smartboot.tech/smart-servlet/guides/release_note/

原文链接:https://www.oschina.net/news/309910/smart-servlet-2-2
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章