Backend Development 14 min read

Integrating Dataway with Spring Boot for Zero‑Code API Configuration

This tutorial explains how to embed Dataway—a DataQL‑based API configuration UI—into a Spring Boot application, covering Maven dependencies, property settings, database schema creation, datasource integration, Hasor module registration, enabling annotations, and step‑by‑step usage to publish and test APIs without writing traditional controller code.

Top Architect
Top Architect
Top Architect
Integrating Dataway with Spring Boot for Zero‑Code API Configuration

Dataway is a UI‑driven interface configuration tool built on DataQL that lets developers create API endpoints without writing any Java code; the entire configuration, testing, smoke‑testing, and publishing process is performed through its web interface.

First, add the required Maven dependencies for Hasor and Dataway:

<dependency>
    <groupId>net.hasor</groupId>
    <artifactId>hasor-spring</artifactId>
    <version>4.1.6</version>
</dependency>
<dependency>
    <groupId>net.hasor</groupId>
    <artifactId>hasor-dataway</artifactId>
    <version>4.1.6</version>
</dependency>

Configure Dataway in application.properties (the two flags HASOR_DATAQL_DATAWAY and HASOR_DATAQL_DATAWAY_ADMIN must be set to true for the feature to be active):

# Enable Dataway
HASOR_DATAQL_DATAWAY=true
HASOR_DATAQL_DATAWAY_ADMIN=true
# Optional URLs
HASOR_DATAQL_DATAWAY_API_URL=/api/
HASOR_DATAQL_DATAWAY_UI_URL=/interface-ui/
# SQL dialect
HASOR_DATAQL_FX_PAGE_DIALECT=mysql

Dataway requires two MySQL tables. Create them with the following DDL (the statements are stored in the Dataway JAR under META-INF/hasor-framework/mysql for MySQL):

CREATE TABLE `interface_info` (
    `api_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `api_method` varchar(12) NOT NULL COMMENT 'HttpMethod: GET,PUT,POST',
    `api_path` varchar(512) NOT NULL COMMENT 'Intercept path',
    `api_status` int(2) NOT NULL COMMENT '0 draft,1 published,2 changed,3 disabled',
    `api_comment` varchar(255) NULL COMMENT 'Comment',
    `api_type` varchar(24) NOT NULL COMMENT 'Script type: SQL,DataQL',
    `api_script` mediumtext NOT NULL COMMENT 'Query script',
    `api_schema` mediumtext NULL COMMENT 'Request/response structure',
    `api_sample` mediumtext NULL COMMENT 'Sample data',
    `api_option` mediumtext NULL COMMENT 'Extended config',
    `api_create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
    `api_gmt_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'Modify time',
    PRIMARY KEY (`api_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Dataway API';

CREATE TABLE `interface_release` (
    `pub_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Publish ID',
    `pub_api_id` int(11) NOT NULL COMMENT 'Related API ID',
    `pub_method` varchar(12) NOT NULL COMMENT 'HttpMethod: GET,PUT,POST',
    `pub_path` varchar(512) NOT NULL COMMENT 'Intercept path',
    `pub_status` int(2) NOT NULL COMMENT '0 active,1 inactive',
    `pub_type` varchar(24) NOT NULL COMMENT 'Script type: SQL,DataQL',
    `pub_script` mediumtext NOT NULL COMMENT 'Query script',
    `pub_script_ori` mediumtext NOT NULL COMMENT 'Original script (SQL only)',
    `pub_schema` mediumtext NULL COMMENT 'Request/response structure',
    `pub_sample` mediumtext NULL COMMENT 'Sample data',
    `pub_option` mediumtext NULL COMMENT 'Extended config',
    `pub_release_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'Publish time',
    PRIMARY KEY (`pub_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Dataway API publish history';

Next, add the datasource libraries (MySQL driver, Druid pool, and Spring Boot JDBC starter) and configure the datasource in application.properties :

# db
spring.datasource.url=jdbc:mysql://
:3306/example
spring.datasource.username=xxxxx
spring.datasource.password=xxxxx
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
# druid
spring.datasource.druid.initial-size=3
spring.datasource.druid.min-idle=3
spring.datasource.druid.max-active=10
spring.datasource.druid.max-wait=60000
spring.datasource.druid.stat-view-servlet.login-username=admin
spring.datasource.druid.stat-view-servlet.login-password=admin
spring.datasource.druid.filter.stat.log-slow-sql=true
spring.datasource.druid.filter.stat.slow-sql-millis=1

If the project already provides a datasource, this step can be skipped.

Create a Hasor module to inject the Spring datasource into the Hasor container:

@DimModule
@Component
public class ExampleModule implements SpringModule {
    @Autowired
    private DataSource dataSource = null;

    @Override
    public void loadModule(ApiBinder apiBinder) throws Throwable {
        // Install the datasource into Hasor
        apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource));
    }
}

Enable Hasor in the Spring Boot main class with the annotations @EnableHasor and @EnableHasorWeb :

@EnableHasor
@EnableHasorWeb
@SpringBootApplication(scanBasePackages = { "net.example.hasor" })
public class ExampleApplication {
    public static void main(String[] args) {
        SpringApplication.run(ExampleApplication.class, args);
    }
}

Run the application; the console will show messages such as dataway api workAt /api/ and dataway admin workAt /interface-ui/ , confirming that Dataway is active.

Open a browser at http://127.0.0.1:8080/interface-ui/ to access the Dataway UI, create a new API either in SQL mode or DataQL mode (e.g., var query = @@sql()<% select * from interface_info %>; return query(); ), save and publish it, then call the endpoint http://127.0.0.1:8080/api/demos to see the result.

The article concludes that Dataway provides a novel, code‑free way to expose data as APIs, dramatically reducing development effort, and provides links to the official manuals and project repositories for further exploration.

Spring BootMySQLAPI ConfigurationDataQLDatawayHasor
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.