发布时间:2026/7/24 17:39:20
让SpringBoot不需要Controller、Service、DAO、Mapper,卧槽!这款工具绝了 Dataway介绍Dataway 是基于 DataQL 服务聚合能力为应用提供的一个接口配置工具。使得使用者无需开发任何代码就配置一个满足需求的接口。整个接口配置、测试、冒烟、发布。一站式都通过 Dataway 提供的 UI 界面完成。UI 会以 Jar 包方式提供并集成到应用中并和应用共享同一个 http 端口应用无需单独为 Dataway 开辟新的管理端口。这种内嵌集成方式模式的优点是可以使得大部分老项目都可以在无侵入的情况下直接应用 Dataway。进而改进老项目的迭代效率大大减少企业项目研发成本。Dataway 工具化的提供 DataQL 配置能力。这种研发模式的变革使得相当多的需求开发场景只需要配置即可完成交付。从而避免了从数据存取到前端接口之间的一系列开发任务例如Mapper、BO、VO、DO、DAO、Service、Controller 统统不在需要。Dataway 是 Hasor 生态中的一员因此在 Spring 中使用 Dataway 首先要做的就是打通两个生态。根据官方文档中推荐的方式我们将 Hasor 和 Spring Boot 整合起来。这里是原文https://www.hasor.net/web/extends/spring/for_boot.html第一步引入相关依赖dependency groupIdnet.hasor/groupId artifactIdhasor-spring/artifactId version4.1.3/version /dependency dependency groupIdnet.hasor/groupId artifactIdhasor-dataway/artifactId version4.1.3-fix20200414/version!-- 4.1.3 包存在UI资源缺失问题 -- /dependencyhasor-spring 负责 Spring 和 Hasor 框架之间的整合。 hasor-dataway 是工作在 Hasor 之上利用 hasor-spring 我们就可以使用 dataway了。第二步配置 Dataway并初始化数据表dataway 会提供一个界面让我们配置接口这一点类似 Swagger 只要jar包集成就可以实现接口配置。找到我们 springboot 项目的配置文件application.properties# 是否启用 Dataway 功能必选默认false HASOR_DATAQL_DATAWAYtrue # 是否开启 Dataway 后台管理界面必选默认false HASOR_DATAQL_DATAWAY_ADMINtrue # dataway API工作路径可选默认/api/ HASOR_DATAQL_DATAWAY_API_URL/api/ # dataway-ui 的工作路径可选默认/interface-ui/ HASOR_DATAQL_DATAWAY_UI_URL/interface-ui/ # SQL执行器方言设置可选建议设置 HASOR_DATAQL_FX_PAGE_DIALECTmysqlDataway 一共涉及到 5个可以配置的配置项但不是所有配置都是必须的。其中HASOR_DATAQL_DATAWAY、HASOR_DATAQL_DATAWAY_ADMIN两个配置是必须要打开的默认情况下 Datawaty 是不启用的。Dataway 需要两个数据表才能工作下面是这两个数据表的简表语句。下面这个 SQL 可以在 dataway的依赖 jar 包中 “META-INF/hasor-framework/mysql” 目录下面找到建表语句是用 mysql 语法写的。CREATE TABLE interface_info ( api_id int(11) NOT NULL AUTO_INCREMENT COMMENT ID, api_method varchar(12) NOT NULL COMMENT HttpMethodGET、PUT、POST, api_path varchar(512) NOT NULL COMMENT 拦截路径, api_status int(2) NOT NULL COMMENT 状态0草稿1发布2有变更3禁用, api_comment varchar(255) NULL COMMENT 注释, api_type varchar(24) NOT NULL COMMENT 脚本类型SQL、DataQL, api_script mediumtext NOT NULL COMMENT 查询脚本xxxxxxx, api_schema mediumtext NULL COMMENT 接口的请求/响应数据结构, api_sample mediumtext NULL COMMENT 请求/响应/请求头样本数据, api_create_time datetime DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间, api_gmt_time datetime DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间, PRIMARY KEY (api_id) ) ENGINEInnoDB AUTO_INCREMENT0 DEFAULT CHARSETutf8mb4 COMMENTDataway 中的API; CREATE TABLE interface_release ( pub_id int(11) NOT NULL AUTO_INCREMENT COMMENT Publish ID, pub_api_id int(11) NOT NULL COMMENT 所属API ID, pub_method varchar(12) NOT NULL COMMENT HttpMethodGET、PUT、POST, pub_path varchar(512) NOT NULL COMMENT 拦截路径, pub_status int(2) NOT NULL COMMENT 状态0有效1无效可能被下线, pub_type varchar(24) NOT NULL COMMENT 脚本类型SQL、DataQL, pub_script mediumtext NOT NULL COMMENT 查询脚本xxxxxxx, pub_script_ori mediumtext NOT NULL COMMENT 原始查询脚本仅当类型为SQL时不同, pub_schema mediumtext NULL COMMENT 接口的请求/响应数据结构, pub_sample mediumtext NULL COMMENT 请求/响应/请求头样本数据, pub_release_timedatetime DEFAULT CURRENT_TIMESTAMP COMMENT 发布时间下线不更新, PRIMARY KEY (pub_id) ) ENGINEInnoDB AUTO_INCREMENT0 DEFAULT CHARSETutf8mb4 COMMENTDataway API 发布历史。; create index idx_interface_release on interface_release (pub_api_id);第三步配置数据源作为 Spring Boot 项目有着自己完善的数据库方面工具支持。我们这次采用 druid mysql spring-boot-starter-jdbc 的方式。首先引入依赖dependency groupIdmysql/groupId artifactIdmysql-connector-java/artifactId version5.1.30/version /dependency dependency groupIdcom.alibaba/groupId artifactIddruid/artifactId version1.1.21/version /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jdbc/artifactId /dependency dependency groupIdcom.alibaba/groupId artifactIddruid-spring-boot-starter/artifactId version1.1.10/version /dependency然后增加数据源的配置# db spring.datasource.urljdbc:mysql://xxxxxxx:3306/example spring.datasource.usernamexxxxx spring.datasource.passwordxxxxx spring.datasource.driver-class-namecom.mysql.jdbc.Driver spring.datasource.type:com.alibaba.druid.pool.DruidDataSource # druid spring.datasource.druid.initial-size3 spring.datasource.druid.min-idle3 spring.datasource.druid.max-active10 spring.datasource.druid.max-wait60000 spring.datasource.druid.stat-view-servlet.login-usernameadmin spring.datasource.druid.stat-view-servlet.login-passwordadmin spring.datasource.druid.filter.stat.log-slow-sqltrue spring.datasource.druid.filter.stat.slow-sql-millis1如果项目已经集成了自己的数据源那么可以忽略第三步。第四步把数据源设置到 Hasor 容器中Spring Boot 和 Hasor 本是两个独立的容器框架我们做整合之后为了使用 Dataway 的能力需要把 Spring 中的数据源设置到 Hasor 中。首先新建一个 Hasor 的 模块并且将其交给 Spring 管理。然后把数据源通过 Spring 注入进来。DimModule Component public class ExampleModule implements SpringModule { Autowired private DataSource dataSource null; Override public void loadModule(ApiBinder apiBinder) throws Throwable { // .DataSource form Spring boot into Hasor apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource)); } }Hasor 启动的时候会调用 loadModule 方法在这里再把 DataSource 设置到 Hasor 中。第五步在SprintBoot 中启用 HasorEnableHasor() EnableHasorWeb() SpringBootApplication(scanBasePackages { net.example.hasor }) public class ExampleApplication { public static void main(String[] args) { SpringApplication.run(ExampleApplication.class, args); } }这一步非常简单只需要在 Spring 启动类上增加两个注解即可。第六步启动应用应用在启动过程中会看到 Hasor Boot 的欢迎信息_ _ ____ _ | | | | | _ \ | | | |__| | __ _ ___ ___ _ __ | |_) | ___ ___ | |_ | __ |/ _ / __|/ _ \| __| | _ / _ \ / _ \| __| | | | | (_| \__ \ (_) | | | |_) | (_) | (_) | |_ |_| |_|\__,_|___/\___/|_| |____/ \___/ \___/ \__|在后面的日志中还可以看到类似下面这些日志。2020-04-14 13:52:59.696 [main] INFO n.h.core.context.TemplateAppContext - loadModule class net.hasor.dataway.config.DatawayModule 2020-04-14 13:52:59.697 [main] INFO n.hasor.dataway.config.DatawayModule - dataway api workAt /api/ 2020-04-14 13:52:59.697 [main] INFO n.h.c.e.AbstractEnvironment - var - HASOR_DATAQL_DATAWAY_API_URL /api/. 2020-04-14 13:52:59.704 [main] INFO n.hasor.dataway.config.DatawayModule - dataway admin workAt /interface-ui/ 2020-04-14 13:52:59.716 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[901d38f22faa419a8593bb349905ed0e] - bindType ‘class net.hasor.dataway.web.ApiDetailController’ mappingTo: ‘[/interface-ui/api/api-detail]’. 2020-04-14 13:52:59.716 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[c6eb9f3b3d4c4c8d8a4f807435538172] - bindType ‘class net.hasor.dataway.web.ApiHistoryListController’ mappingTo: ‘[/interface-ui/api/api-history]’. 2020-04-14 13:52:59.717 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[eb841dc72ad54023957233ef602c4327] - bindType ‘class net.hasor.dataway.web.ApiInfoController’ mappingTo: ‘[/interface-ui/api/api-info]’. 2020-04-14 13:52:59.717 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[96aebb46265245459ae21d558e530921] - bindType ‘class net.hasor.dataway.web.ApiListController’ mappingTo: ‘[/interface-ui/api/api-list]’. 2020-04-14 13:52:59.718 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[7467c07f160244df8f228321f6262d3d] - bindType ‘class net.hasor.dataway.web.ApiHistoryGetController’ mappingTo: ‘[/interface-ui/api/get-history]’. 2020-04-14 13:52:59.719 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[97d8da5363c741ba99d87c073a344412] - bindType ‘class net.hasor.dataway.web.DisableController’ mappingTo: ‘[/interface-ui/api/disable]’. 2020-04-14 13:52:59.720 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[8ddc3316ef2642dfa4395ca8ac0fff04] - bindType ‘class net.hasor.dataway.web.SmokeController’ mappingTo: ‘[/interface-ui/api/smoke]’. 2020-04-14 13:52:59.720 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[cc06c5fb343b471aacedc58fb2fe7bf8] - bindType ‘class net.hasor.dataway.web.SaveApiController’ mappingTo: ‘[/interface-ui/api/save-api]’. 2020-04-14 13:52:59.720 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[7915b2b1f89a4e73891edab0264c9bd4] - bindType ‘class net.hasor.dataway.web.PublishController’ mappingTo: ‘[/interface-ui/api/publish]’. 2020-04-14 13:52:59.721 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[0cfa34586455414591bdc389bff23ccb] - bindType ‘class net.hasor.dataway.web.PerformController’ mappingTo: ‘[/interface-ui/api/perform]’. 2020-04-14 13:52:59.721 [main] INFO net.hasor.core.binder.ApiBinderWrap - mapingTo[37fe4af3e2994acb8deb72d21f02217c] - bindType ‘class net.hasor.dataway.web.DeleteController’ mappingTo: ‘[/interface-ui/api/delete]’.当看到 “dataway api workAt/api/” 、 dataway admin workAt/interface-ui/信息时就可以确定 Dataway 的配置已经生效了。第七步访问接口管理页面进行接口配置在浏览器中输入 “http://127.0.0.1:8080/interface-ui/” 就可以看到期待已久的界面了。图片第八步新建一个接口Dataway 提供了2中语言模式我们可以使用强大的 DataQL 查询语言也可以直接使用 SQL 语言在 Dataway 内部 SQL 语言也会被转换为 DataQL 的形式执行。图片首先我们在 SQL 模式下尝试执行一条 select 查询立刻就可以看到这条 SQL 的查询结果。图片同样的方式我们使用 DataQL 的方式需要这样写var query sql()% select * from interface_info % return query()其中 var query sql()% ... %是用来定义SQL外部代码块并将这个定义存入 query 变量名中。% % 中间的就是 SQL 语句。最后在 DataQL 中调用这个代码块并返回查询结果。当接口写好之后就可以保存发布了为了测试方便我选用 GET 方式。图片接口发布之后我们直接请求http://127.0.0.1:8080/api/demos就看到期待已久的接口返回值了。图片最后总结经过上面的几个步骤我们介绍了如何基于 Spring Boot 项目使用 Dataway 来简单的配置接口。Dataway 的方式确实给人耳目一新一个接口竟然可以如此简单的配置出来无需开发任何一行代码也不需要做任何 Mapping 实体映射绑定。

相关新闻

2026/7/24 17:39:20

OpenForge RL:适配任意环境的智能体运行时原生训练框架

OpenForge RL:适配任意环境的智能体运行时原生训练框架 论文原链接:https://arxiv.org/html/2607.21557v1 摘要 现代大模型智能体普遍依赖复杂运行时((\mathcal{H})arness)(如Claude Code、Codex、OpenClaw&#xff09…

2026/7/24 17:39:20

大模型选型与实战:从入门到进阶的AI应用指南

1. 大模型入门:从零开始理解AI巨无霸第一次接触"大模型"这个词时,我正盯着电脑屏幕发呆,心想这玩意儿跟普通AI有什么区别?直到亲眼见证ChatGPT在3秒内写完我憋了3小时的周报,才意识到技术变革已经来到家门口…

2026/7/24 19:09:25

电力系统科研人的“数据痛点”,终于有解了

引言:电力系统研究,为什么绕不开气象数据?如果你做的是电力系统方向的研究,尤其是新能源并网、电力系统规划、储能配置这些课题,你一定会遇到一个问题:需要气象数据,但不知道怎么搞。这不是你一…

2026/7/24 19:09:25

零基础AI换脸神器:roop-unleashed终极快速入门指南

零基础AI换脸神器:roop-unleashed终极快速入门指南 【免费下载链接】roop-unleashed Evolved Fork of roop with Web Server and lots of additions 项目地址: https://gitcode.com/gh_mirrors/ro/roop-unleashed 想要体验电影级别的面部替换特效&#xff0c…

2026/7/24 19:09:25

Chrome滚动截图神器:一键保存完整网页的终极解决方案

Chrome滚动截图神器:一键保存完整网页的终极解决方案 【免费下载链接】full-page-screen-capture-chrome-extension One-click full page screen captures in Google Chrome 项目地址: https://gitcode.com/gh_mirrors/fu/full-page-screen-capture-chrome-extens…

2026/7/24 19:04:25

新手入门漏洞挖掘:从Web安全基础到实战SQL注入

1. 项目概述:从零开始的漏洞挖掘实战入门最近总能看到一些标题很吸引人的内容,比如“手把手教你挖漏洞月入过万”,很多刚接触网络安全的朋友,尤其是学生和想转行的朋友,看了之后既兴奋又迷茫。兴奋的是似乎找到了一条“…

2026/7/23 12:54:51

Unity与Python本地通信:基于Flask的跨语言数据交换实战

1. 项目概述:为什么我们需要一个本地通信服务器?在游戏开发、数字孪生、仿真训练等众多领域,Unity作为强大的实时3D内容创作平台,其核心逻辑通常由C#驱动。然而,当我们需要进行复杂的数据分析、机器学习推理、科学计算…

2026/7/24 0:03:10

不同品牌斜齿行星减速机如何替换?以PX与PAG系列为例

不同品牌斜齿行星减速机如何替换?以 PX 与 PAG 系列为例 一、系列对应不等于型号直接互换 PX 与 PAG 都属于斜齿、方法兰、输出轴式精密行星减速机,结构形式和应用方向具有对应关系。 原设备使用PX系列时,可以优先从PAG系列中寻找替换型号。但…

2026/7/24 0:03:10

jdk8 把list 扁平化成String 多个以逗号分隔

在 JDK 8 中&#xff0c;将 List 扁平化为以逗号分隔的 String&#xff0c;有几种非常简洁且高效的方法。&#x1f680; 推荐方案&#xff1a;使用 Collectors.joining()这是最标准的 Java 8 写法&#xff0c;适用于 List<String>。javaimport java.util.stream.Collecto…

2026/7/24 0:03:10

java 两个 long id 怎么合并成一个long id 并且不重复

“把两个 Long ID 合并成一个唯一的 Long ID&#xff0c;且保证不重复”这个需求&#xff0c;在 Java 里直接做数学上的“完美合并”是不可能的。因为两个 Long&#xff08;各 64 位&#xff09;要合并成一个 Long&#xff08;64 位&#xff09;&#xff0c;在信息论上是有损压…

2026/7/23 23:42:43

3个高效策略:快速掌握Axure中文界面配置

3个高效策略&#xff1a;快速掌握Axure中文界面配置 【免费下载链接】axure-cn Chinese language file for Axure RP. Axure RP 简体中文语言包。支持 Axure 11、10、9。不定期更新。 项目地址: https://gitcode.com/gh_mirrors/ax/axure-cn 还在为Axure RP的英文界面感…