作者:圣峰冰寒_869 | 来源:互联网 | 2023-02-07 18:22
Solon 1.9.0 发布了,使用方法很简单:
pom.xml 添加依赖
org.noear solon-api 1.9.0
添加几行 java 代码,就可以运行
@Controller public class App { public static void main(String[] args) { Solon.start(App.class, args); } @Get @Mapping("/hello") public String hello(@Param(defaultValue = "world") String name) { return String.format("Hello %s!", name); } }
相对于 Spring Boot 和 Spring Cloud 的项目
- 启动快 5 ~ 10 倍
- qps 高 2~ 3 倍
- 运行时内存节省 1/3 ~ 1/2
- 打包可以缩小到 1/2 ~ 1/10(比如,90Mb 的变成了 9Mb)
- 基于 app.name 进行注册发现 与 k8s svc 相互对应
- 支持 Service Mesh 架构部署方案
本次更新
- 新增 grpc-solon-plugin 插件
- 新增 solon.cache.caffeine 插件
- 新增 solon.serialization.fastjson2 插件
- 新增 nami.coder.fastjson2 插件
- 新增 solon.aspect 插件
- 新增 solon.health 插件
-
新增 solon.hotplug 插件
public class DemoApp { public static void main(String[] args) { Solon.start(App.class, args, app -> { //添加待管理的插件 PluginManager.add("add1", "/x/x/x.jar"); PluginManager.add("add2", "/x/x/x2.jar"); app.get("start", ctx -> { //启动插件 PluginManager.start("add1"); ctx.output("OK"); }); app.get("stop", ctx -> { //停止插件 PluginManager.stop("add1"); ctx.output("OK"); }); }); } }
- 新增 solon.config.yaml 插件
- 新增 solon.web.servlet 插件
- 新增 solon.web.staticfiles 插件
- 新增 solon.web.cors 插件
- 插件 solon.extend.aspect [标为弃用]
- 插件 solon.extend.health [标为弃用]
- 插件 solon.extend.hotplug [标为弃用]
- 插件 solon.extend.properties.yaml [标为弃用]
- 插件 solon.extend.servlet [标为弃用]
- 插件 solon.extend.staticfiles [标为弃用]
- 插件 solon.extend.cors [标为弃用]
进一步了解 Solon
- 《想法与架构笔记》
- 《生态预览》
- 《与 Spring Boot 的区别?》
- 《与 Spring Cloud 的区别?》