与 HarmonyOS NEXT 10月8日公测同行。Solon (开放原子开源基金会,孵化项目) v3.0 正式发布,
且将在 2025 年启动华为编程语言 “仓颉” 版开发(届时会有 Solon-Java 和 Solon-CJ 两大版本)。本次大版本更新,费时多月:
- 与 Solon v2.9 保持兼容(向下兼容)
- 与 JDK8, JDK11, JDK17, JDK21, JDK23 保持兼容(全系兼容)
Solon 框架!
Java “新式”应用开发框架,2017~2024。从零开始构建(非 java-ee 架构),有灵活的接口规范与开放生态。
- 追求: 更快、更小、更简单
- 提倡: 克制、简洁、高效、开放、生态
- 官网: https://solon.noear.org
有什么特点?
特点 | 描述 |
---|---|
更高的计算性价比 | 并发高 300%;内存省 50% |
更快的开发效率 | 代码少;入门快;调试重启快 10 倍 |
更好的生产与部署体验 | 打包小 90% |
更大的兼容范围 | 非 java-ee 架构;同时支持 java8 ~ java23,graalvm native image |
更新与兼容详细说明:
1、概述
v3.0 版本主要是,内核删除了 20Kb 的弃用代码及相应的调整。最新内核为 0.3Mb。
- 移除的配置,要认真检查;
- 移除的事件,要认真检查;
- 弃用接口移除等编译时会出错提醒,问题不大。
新增或重构插件有:
- solon-data-sqlutils(编译大小为 10Kb 的小工具)
- solon-web-webservices
- solon-net-stomp
- nami-channel-http(用于替代 nami-channel-http-okhttp)
- solon-net-httputils(重构,添加 HttpURLConnection 适配;编译大小为 40Kb)
2、弃用配置移除对应表(要认真检查)
- 移除
类型 | 移除配置名 | 替代配置名 | |
---|---|---|---|
启动参数 | solon:: | ||
- config | config.add | ||
应用属性 | solon:: | ||
- solon.config | solon.config.add |
- 弃用
类型 | 弃用配置名 | 替代配置名 | |
---|---|---|---|
应用属性 | solon-boot:: | ||
- server.session.state.domain | server.session.cookieDomain | ||
- server.session.state.domain.auto | server.session.cookieDomainAuto | ||
solon-web-staticfiles:: | |||
- solon.staticfiles.maxAge | solon.staticfiles.cacheMaxAge |
3、弃用事件移除对应表(要认真检查)
插件 | 移除事件 | 替代方案 | |
---|---|---|---|
solon | @Bean bean? | getBeanAsync(…class, …) / @Inject .. | |
@Component bean? | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-fastjson | FastjsonActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
FastjsonRenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-fastjson2 | Fastjson2ActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
Fastjson2RenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-fury | FuryActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
solon-serialization-gson | GsonActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
GsonRenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-hessian | HessianActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
solon-serialization-jackson | JacksonActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
JacksonRenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-jackson-xml | JacksonXmlActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
JacksonXmlRenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-properties | PropertiesActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
PropertiesRenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-serialization-protostuff | ProtostuffActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
solon-serialization-snack3 | SnackActionExecutor | getBeanAsync(…class, …) / @Inject .. | |
SnackRenderFactory | getBeanAsync(…class, …) / @Inject .. | ||
solon-view-beetl | GroupTemplate | getBeanAsync(BeetlRender.class, …) / @Inject .. | |
solon-view-enjoy | Engine | getBeanAsync(EnjoyRender.class, …) / @Inject .. | |
solon-view-freemarker | Configuration | getBeanAsync(FreemarkerRender.class, …) / @Inject .. | |
solon-view-thymeleaf | TemplateEngine | getBeanAsync(ThymeleafRender.class, …) / @Inject .. | |
solon-view-velocity | RuntimeInstance | getBeanAsync(VelocityRender.class, …) / @Inject .. |
以上事件替代的扩展方案(示例):
@Configuration
public class App {
public static void main(String[] args) {
Solon.start(App.class, args, app -> {
//1.第一时间手动获取(在其它注入前执行)
app.context().getBeanAsync(Xxx.class, e -> {
});
});
}
//2.由扫描时自动注入
@Bean
public void cfg(Xxx xxx) {
}
}
什么时候用事件扩展好(尽量不用)?
- 需要及时扩展,但又不方便进入容器的对象。
4、弃用 Before、After 处理体系移除(编译会有提醒)
影响 | 替代方案 |
---|---|
全局方面 | 由 RouterInterceptor 替代 |
本地网关方面 | 由 Filter 替代,或者自己可扩展 |
注解方面(控制器相关) | 由 @Addition(Filter) 替代 |
其中“本地网关”,可以通过定制恢复旧版能力:https://solon.noear.org/article/214
5、弃用类型移除对应表(编译会有提醒)
插件 | 移除类型 | 替代类型 | |
---|---|---|---|
nami | |||
@Body | @NamiBody | ||
NamiBodyAnno | |||
@Mapping | @NamiMapping | ||
NamiMappingAnno | |||
solon | |||
@PathVar | @Path | ||
@PropertySource | @Import | ||
@ProxyComponent | @Component | ||
@Before(Handler) | @Addition(Filter) | ||
@After(Handler) | @Addition(Filter) | ||
Endpoint | / | ||
SolonBuilder | / | ||
ValHolder | / | ||
InitializingBean | @Init | ||
NdMap | IgnoreCaseMap<Object> | ||
solon-data | |||
Serializer | core::Serializer | ||
solon-data-dynamicds | |||
DynamicDsHolder | DynamicDsKey | ||
solon-logging | |||
LogUtilToSlf4j | / | ||
solon-logging-log4j | |||
SolonCloudAppender | / | ||
solon-logging-logback | |||
SolonCloudAppender | / | ||
solon-serialization | |||
JsonConverter | core::Converter | ||
StringSerializer | core::Serializer<String> | ||
solon-test | |||
@TestPropertySource | @Import | ||
@TestRollback | @Rollback | ||
AbstractHttpTester | HttpTester | ||
HttpTestBase | HttpTester |
6、弃用接口方法移除对应表(编译会有提醒)
调整类 | 移除方法(或字段) | 替代方法 | |
---|---|---|---|
nami:: | |||
- Constants | CONTENT_TYPE_* | ||
solon:: | |||
- ActionParamResolver | resolvePathVar() | ||
- ActionDefault | before(.) | / 只留 filter 体系 | |
after(.) | / | ||
- AppContext | beanOnloaded(.) | lifecycle(.) | |
- Bean | registered() | delivered() | |
- BeanContainer | getAttrs() | attachment*(.) | |
beanAround*(.) | beanInterceptor*(.) | ||
- ClassUtil | newInstance(.) | tryInstance(.) | |
- ClassWrap | getFieldAllWraps() | getFieldWraps() | |
- Component | registered() | delivered() | |
- ConditionUtil | ifMissing(.) | ifMissingBean(.) | |
- Context | ip() | remoteIp() | |
param(key,def) | paramOrDefault(key,def) | ||
paramSet(.) | paramMap().add(.) | ||
paramsMap() | paramMap().toValuesMap() | ||
paramsAdd(.) | paramMap().add(.) | ||
files(.) | fileValues(.) | ||
filesMap() | fileMap().toValuesMap() | ||
cookie(key,def) | cookieOrDefault(key,def) | ||
header(key,def) | headerOrDefault(key,def) | ||
headersMap() | headerMap().toValuesMap() | ||
session(key,def) | sessionOrDefault(key,def) | ||
statusSet(.) | status(.) | ||
attr(key,def) | attrOrDefault(key,def) | ||
attrClear() | attrsClear() | ||
- DateAnalyzer | getGlobal() | global() | |
- EventBus | pushAsync() | publishAsync() | |
pushTry() | publishTry() | ||
push() | publish() | ||
- Gateway | before(.) | / 只留 filter 体系 | |
after(.) | / | ||
- LifecycleBean | prestop() | preStop() | |
- LogUtil | debugAsync() | / | |
infoAsync() | / | ||
- MethodHolder | getArounds() | getInterceptors() | |
- MethodWrap | getArounds() | getInterceptors() | |
- MvcFactory | resolveParam(.) | resolveActionParam(.) | |
- NvMap | (map) | from(map) | |
getBean(.) | toBean(.) | ||
- Props | getByParse(.) | getByTmpl(.) | |
getXmap(.) | getMap(.) | ||
getBean(.) | toBean(.) | ||
- RenderManager | mapping(.) | Solon.app().render(key, ) | |
register(.) | Solon.app().render(null, .) | ||
- ResourceUtil | remClasspath(.) | remSchema(.) | |
- Router | matchOne(.) | matchMain(.) | |
- RunUtil | setExecutor(.) | setParallelExecutor(.) | |
- SolonApp | before(.) | / 只留 filter 体系 | |
after(.) | / | ||
- SolonProps | source() | app.source() | |
sourceLocation() | app.sourceLocation() | ||
- Utils | TAG_classpath | / | |
resolvePaths(.) | / | ||
hasClass(.) | ClassUtil.hasClass(.) | ||
loadClass(.) | ClassUtil.loadClass(.) | ||
newInstance(.) | ClassUtil.tryInstance(.) | ||
getResource*(.) | ResourceUtil.getResource*(.) | ||
transferTo*(.) | IoUtil.transferTo*(.) | ||
buildExt(.) | getFolderAndMake(.) | ||
solon-boot:: | |||
- HttpServerConfigure | allowSsl(.) | enableSsl(.) | |
solon-data:: | |||
- CacheService | get(key) | get(key, type) | |
solon-scheduling:: | |||
- IJobManager | setJobInterceptor(.) | addJobInterceptor(.) | |
solon-serialization-properties:: | |||
- PropertiesActionExecutor | includeFormUrlencoded(.) | allowPostForm(.) |
7、弃用插件移除对应表
其中简化了快捷组合包(发现太多,容易混乱),只留两个基础的:
- solon-lib(保持不变)
- solon-web(移除了 solon-view-freemarker)
移除插件 | 替代插件 | 备注 |
---|---|---|
:: cloud | ||
solon.cloud.httputils | solon-net-httputils | |
:: detector | ||
detector-solon-plugin | solon-health-detector | |
:: logging | ||
log4j2-solon-plugin | solon-logging-log4j2 | |
logback-solon-plugin | solon-logging-logback | |
:: scheduling | ||
solon.extend.schedule | / | |
:: testing | ||
solon.test | solon-test | |
:: web | ||
solon.web.flux | solon-web-rx | |
:: shortcuts | ||
solon-api | solon-web | |
solon-job | / | 改用 solon-lib + |
solon-rpc | / | 改用 solon-web + |
solon-beetl-web | / | 改用 solon-web + |
solon-enjob-web | / | 改用 solon-web + |
solon-web-beetl | / | 改用 solon-web + |
solon-web-enjoy | / | 改用 solon-web + |
solon-cloud-alibaba | / | 改用 solon-web + solon-cloud + |
solon-cloud-water | / | 改用 solon-web + solon-cloud + |
移除的快捷组合包,可通过以下方式组合:
- solon-job=
- solon-lib + solon-scheduling-simple
- solon-rpc=
- solon-web + nami-coder-snack3 + nami-channl-http-okhttp
- solon-beetl-web(或 solon-web-beetl)=
- solon-web + solon-view-beetl + beetlsql-solon-plugin
- solon-enjoy-web(或 solon-web-enjoy)=
- solon-web + solon-view-enjoy + activerecord-solon-plugin
- solon-cloud-alibaba=
- solon-web + solon-cloud + nacos-solon-cloud-plugin + rocketmq-solon-cloud-plugin + sentinel-solon-cloud-plugin
- solon-cloud-water=
- solon-web + solon-cloud + water-solon-cloud-plugin
8、部分插件名字调整对应表(旧名标为弃用,仍可用)
新的调整按以下插件命名规则执行:
插件命名规则 | 说明 |
---|---|
solon-*(由 solon.* 调整而来) | 表示内部架构插件 |
*-solon-plugin(保持不变) | 表示外部适配插件 |
*-solon-cloud-plugin(保持不变) | 表过云接口外部适配插件 |
对应的“旧名”,仍可使用。预计会保留一年左右。具体调整如下:
新名 | 旧名 | 备注 |
---|---|---|
:: nami | ||
nami-channel-http-hutool | nami.channel.http.hutool | |
nami-channel-http-okhttp | nami.channel.http.okhttp | |
nami-channel-socketd | nami.channel.socketd | |
nami-coder-fastjson | nami.coder.fastjson | |
nami-coder-fastjson2 | nami.coder.fastjson2 | |
nami-coder-fury | nami.coder.fury | |
nami-coder-hessian | nami.coder.hessian | |
nami-coder-jackson | nami.coder.jackson | |
nami-coder-protostuff | nami.coder.protostuff | |
nami-coder-snack3 | nami.coder.snack3 | |
:: base | ||
solon-config-banner | solon.banner | |
solon-config-yaml | solon.config.yaml | |
solon-config-plus | 从原 solon.config.yaml 里拆出来 | |
solon-hotplug | solon.hotplug | |
solon-i18n | solon.i18n | |
solon-mvc | solon.mvc | |
solon-proxy | solon.proxy | |
solon-rx | 新增 | |
:: boot | ||
solon-boot-jdkhttp | solon.boot.jdkhttp | |
solon-boot-jetty-add-jsp | solon.boot.jetty.add.jsp | |
solon-boot-jetty-add-websocket | solon.boot.jetty.add.websocket | |
solon-boot-jetty | solon.boot.jetty | |
solon-boot-jlhttp | solon.boot.jlhttp | |
solon-boot-smarthttp | solon.boot.smarthttp | |
solon-boot-socketd | solon.boot.socketd | |
solon-boot-undertow-add-jsp | solon.boot.undertow.add.jsp | |
solon-boot-undertow | solon.boot.undertow | |
solon-boot-vertx | solon.boot.vertx | |
solon-boot-websocket-netty | solon.boot.websocket.netty | |
solon-boot-websocket | solon.boot.websocket | |
solon-boot | solon.boot | |
:: cloud | ||
solon-cloud-eventplus | solon.cloud.eventplus | |
solon-cloud-gateway | solon.cloud.gateway | |
solon-cloud-metrics | solon.cloud.metrics | |
solon-cloud-tracing | solon.cloud.tracing | |
solon-cloud | solon.cloud | |
:: data | ||
solon-cache-caffeine | solon.cache.caffeine | |
solon-cache-jedis | solon.cache.jedis | |
solon-cache-redisson | solon.cache.redisson | |
solon-cache-spymemcached | solon.cache.spymemcached | |
solon-data-dynamicds | solon.data.dynamicds | |
solon-data-shardingds | solon.data.shardingds | |
solon-data | solon.data | |
:: detector | ||
solon-health-detector | solon.health.detector | |
solon-health | solon.health | |
:: docs | ||
solon-docs-openapi2 | solon.docs.openapi2 | |
solon-docs-openapi3 | ||
solon-docs | solon.docs | |
:: faas | ||
solon-faas-luffy | solon.luffy | |
:: logging | ||
solon-logging-log4j2 | solon.logging.log4j2 | |
solon-logging-logback | solon.logging.logback | |
solon-logging-simple | solon.logging.simple | |
solon-logging | solon.logging | |
:: native | ||
solon-aot | solon.aot | |
::net | ||
solon-net-httputils | solon.net.httputils | |
solon-net-stomp | ||
solon-net | solon.net | |
:: scheduling | ||
solon-scheduling-quartz | solon.scheduling.quartz | |
solon-scheduling-simple | solon.scheduling.simple | |
solon-scheduling | solon.scheduling | |
:: security | ||
solon-security-auth | solon.auth | 旧名弃用 |
solon-security-validation | solon.validation | 旧名弃用 |
solon-security-vault | solon.vault | 旧名弃用 |
solon-security-auth | solon.security.auth | |
solon-security-validation | solon.security.validation | |
solon-security-vault | solon.security.vault | |
:: serialization | ||
solon-serialization | solon.serialization | |
solon-serialization-fastjson | solon.serialization.fastjson | |
solon-serialization-fastjson2 | solon.serialization.fastjson2 | |
solon-serialization-fury | solon.serialization.fury | |
solon-serialization-gson | solon.serialization.gson | |
solon-serialization-hessian | solon.serialization.hessian | |
solon-serialization-jackson | solon.serialization.jackson | |
solon-serialization-jackson-xml | solon.serialization.jackson.xml | |
solon-serialization-kryo | 略过(未发布) | |
solon-serialization-properties | solon.serialization.properties | |
solon-serialization-protostuff | solon.serialization.protostuff | |
solon-serialization-snack3 | solon.serialization.snack3 | |
:: view | ||
solon-view | solon.view | |
solon-view-beetl | solon.view.beetl | |
solon-view-enjoy | solon.view.enjoy | |
solon-view-freemarker | solon.view.freemarker | |
solon-view-jsp | solon.view.jsp | |
solon-view-jsp-jakarta | 略过(未发布) | |
solon-view-thymeleaf | solon.view.thymeleaf | |
solon-view-velocity | solon.view.velocity | |
:: web | ||
solon-sessionstate-jedis | solon.sessionstate.jedis | |
solon-sessionstate-jwt | solon.sessionstate.jwt | |
solon-sessionstate-local | solon.sessionstate.local | |
solon-sessionstate-redisson | solon.sessionstate.redisson | |
solon-web-cors | solon.web.cors | |
solon-web-rx | solon.web.rx | |
solon-web-sdl | solon.web.sdl | |
solon-web-servlet | solon.web.servlet | |
solon-web-servlet-jakarta | solon.web.servlet.jakarta | |
solon-web-sse | solon.web.sse | |
solon-web-staticfiles | solon.web.staticfiles | |
solon-web-stop | solon.web.stop | |
solon-web-webdav | solon.web.webdav |