Backend Development 15 min read

Integrating Dataway with Spring Boot for Zero‑Code API Configuration

This tutorial explains how to embed Dataway—a UI‑driven API configuration tool based on Hasor—into a Spring Boot application, covering dependency inclusion, Dataway property setup, datasource configuration, Hasor module wiring, enabling annotations, launching the service, and creating and publishing APIs without writing any Java code.

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

Dataway is a UI‑based interface configuration tool built on Hasor’s DataQL service aggregation, allowing developers to define complete APIs without writing a single line of code. The tool provides a one‑stop UI for configuring, testing, smoke‑checking, and publishing interfaces, and runs on the same HTTP port as the host application.

Step 1: Add Required Dependencies

<dependency>
    <groupId>net.hasor</groupId>
    <artifactId>hasor-spring</artifactId>
    <version>4.1.3</version>
</dependency>
<dependency>
    <groupId>net.hasor</groupId>
    <artifactId>hasor-dataway</artifactId>
    <version>4.1.3-fix20200414</version>
    <!-- UI resources missing in 4.1.3 -->
</dependency>

hasor-spring integrates Spring and Hasor, while hasor-dataway provides the Dataway capabilities on top of Hasor.

Step 2: Configure Dataway and Initialise Tables

Add the following properties to application.properties (only the two marked properties are mandatory):

# Enable Dataway (default false)
HASOR_DATAQL_DATAWAY=true

# Enable Dataway admin UI (default false)
HASOR_DATAQL_DATAWAY_ADMIN=true

# Optional: API base path (default /api/)
HASOR_DATAQL_DATAWAY_API_URL=/api/

# Optional: Admin UI base path (default /interface-ui/)
HASOR_DATAQL_DATAWAY_UI_URL=/interface-ui/

# Optional: SQL dialect (recommended)
HASOR_DATAQL_FX_PAGE_DIALECT=mysql

Dataway requires two tables ( interface_info and interface_release ) which can be created from the SQL scripts bundled in the hasor-dataway JAR (MySQL syntax).

Step 3: Configure the Data Source

Include the JDBC driver and Druid pool dependencies:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.30</version>
</dependency>
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.1.21</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
    <version>1.1.10</version>
</dependency>

Then configure the datasource in application.properties (example for MySQL with Druid):

# Enable Dataway
HASOR_DATAQL_DATAWAY=true
HASOR_DATAQL_DATAWAY_ADMIN=true

spring.datasource.url=jdbc:mysql://
:3306/example
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

# Druid pool settings
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

Step 4: Register the DataSource in the Hasor Container

Create a Hasor module and inject the Spring datasource:

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

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

Step 5: Enable Hasor in the Spring Boot Application

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

The two annotations automatically register Hasor and its web UI.

Step 6: Start the Application

When the application starts, the console prints Hasor boot messages indicating that Dataway API is mounted at /api/ and the admin UI at /interface-ui/ .

Step 7: Open the Dataway UI

Visit http://127.0.0.1:8080/interface-ui/ in a browser to see the Dataway management interface.

Step 8: Create a New Interface

In the UI you can create an API either in SQL mode or DataQL mode. For example, a simple SQL query:

SELECT * FROM interface_info;

Or the equivalent DataQL script:

var query = @sql()<% 
    select * from interface_info 
%>;
return query();

After saving and publishing (choose GET method for testing), the API becomes reachable at http://127.0.0.1:8080/api/demos , returning the query result.

Conclusion

The guide demonstrates how to integrate Dataway into a Spring Boot project, enabling zero‑code API creation and management. By leveraging Hasor and Dataway, developers can avoid writing boilerplate mapper, DTO, service, and controller classes, dramatically reducing development effort for data‑driven endpoints.

Useful links:

Dataway official manual: https://www.hasor.net/web/dataway/about.html

Dataway project on OSChina: https://www.oschina.net/p/dataway

DataQL documentation: https://www.hasor.net/web/dataql/what_is_dataql.html

Hasor homepage: https://www.hasor.net/web/index.html

BackendJavaSpring BootAPI ConfigurationDatawayHasor
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.