This project is a simple example of how to use Spring WebFlux and R2DBC with Kotlin. It provides a RESTful API for CRUD operations on a database table.
- Uses Spring WebFlux for reactive HTTP requests
- Uses R2DBC for reactive database access
- Provides a RESTful API for CRUD operations on a database table
To use this project, clone it to your local machine and open the project directory in your favorite IDE.
Prerequisites
- Java 17 or later
- Kotlin 1.8.22 or later
- Gradle Kotlin DSL
- Database Server
The member table can be created using the following SQL statement:
CREATE TABLE member (
id BIGINT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
age INT NOT NULL,
created_at TIMESTAMP(3) NOT NULL,
updated_at TIMESTAMP(3) NOT NULL
);
To run this project, you will need to add the following environment variables to your application.yml
file
R2DBC_URL
R2DBC_ID
R2DBC_PW
GET /members
GET /members/:memberName
Path Variables | Type | Description |
---|---|---|
memberName |
String |
Required. Name of member |
POST /members
Body | Type | Description |
---|---|---|
name |
String |
Required. Name of member |
age |
Int |
Required. Age of member |
PUT /members/:memberId
Path Variables | Type | Description |
---|---|---|
memberId |
Long |
Required. Id of member |
Body | Type | Description |
---|---|---|
name |
String |
Required. Name of member |
age |
Int |
Required. Age of member |
DELETE /members/:memberId
Path Variables | Type | Description |
---|---|---|
memberId |
Long |
Required. Id of member |
If you would like to contribute to this project, please create a pull request with your changes.