Examples
The repository contains two runnable Spring Boot applications that expose the same REST API:
| Project | Web stack | Kuery Client API |
|---|---|---|
spring-data-r2dbc | Spring WebFlux + coroutines | KueryClient |
spring-data-jdbc | Spring WebMVC | KueryBlockingClient |
Both demonstrate dynamic SQL, collection binding, generated values, custom converters, programmatic and declarative transactions, and Micrometer Observation with Prometheus.
Prerequisites
- Java 17 or later
- Docker with the Compose plugin
- A clone of the Kuery Client repository
The examples use the repository source through Gradle composite builds, so you do not need to publish artifacts locally.
Start MySQL
From the repository root:
cd examples
docker compose up -d
./init_mysql.shThis starts MySQL 8.0.37 on localhost:13306; the initialization script waits for it to accept connections, creates the testdb database, and inserts sample users and orders. The script is not idempotent, so run it once for a newly created container.
Run an application
Continue from the examples directory. Run one application at a time because both listen on port 8080:
../gradlew :spring-data-r2dbc:bootRun../gradlew :spring-data-jdbc:bootRunWait until Spring Boot reports that the application has started, then try the API from another terminal.
Try the API
# List the two seeded users
curl http://localhost:8080/users
# Fetch one user
curl http://localhost:8080/users/1
# Exercise collection binding with an IN clause
curl 'http://localhost:8080/users?usernames=user1&usernames=user2'
# Fetch a mapped join result
curl http://localhost:8080/users/1/orders
# Inspect Kuery Client metrics
curl http://localhost:8080/actuator/prometheus | grep kuery_clientThe list request returns data shaped like:
[
{"userId":1,"username":"user1","email":"user1@example.com"},
{"userId":2,"username":"user2","email":"user2@example.com"}
]Read the matching ExampleApplication.kt to compare the R2DBC and JDBC implementations:
Stop and reset
Stop the application with Ctrl+C, then remove the example container and its data:
docker compose downRun the start and initialization steps again to get a clean database.