Skip to content

Commit 14c82fa

Browse files
Upgrade to Java 21 and OpenAPI Swagger UI works
1 parent 7efa609 commit 14c82fa

File tree

18 files changed

+88
-123
lines changed

18 files changed

+88
-123
lines changed

.cursorrules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You are an experienced Senior Java Developer, You always adhere to SOLID princip
66

77
Technology stack:
88

9-
Framework: Java Spring Boot 3 Maven with Java 21 Dependencies: Spring WebFlux, Spring Data JPA, Lombok, MySQL driver, Spring Data R2DBC
9+
Framework: Java Spring Boot 3 Gradle with Java 21 Dependencies: Spring WebFlux, Spring Data JPA, Lombok, Postgres driver, Spring Data R2DBC
1010

1111
Application Logic Design:
1212

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ out/
3434

3535
### VS Code ###
3636
.vscode/
37-
db/mysql_data
3837
spring-boot-logger.log
3938
logs
39+
db/postgres_data/

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ MAKEFILE_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
1313
help: ## Display this help screen
1414
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
1515

16-
.PHONY: clean
17-
clean: ## Cleanup database environment
18-
rm -fR ./db/mysql_data
19-
2016
.PHONY: down
2117
down: ## Docker compose down
2218
docker-compose down;
@@ -31,6 +27,10 @@ devBoot: ## Run development environment
3127

3228
.PHONY: run
3329
run: ## Run production environment
30+
docker-compose up;
31+
32+
.PHONY: run_init
33+
run_init: ## Run production environment with initialization
3434
docker-compose up --build;
3535

3636
.PHONY: genapi

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A sample of Spring boot WebFlux and Kotlin Coroutine with Handler and Router. In
66

77
# Reqirements
88
- Java 21
9-
- Docker 4.37.1 >=
9+
- Docker 4.37.2 >=
1010
- gradle 8.12 >=
1111

1212
# Getting Started
@@ -18,7 +18,7 @@ $ make run
1818
```
1919
`application.yml` will be referred for the configuration. This command does
2020
- Build Docker image with the implementation
21-
- Spin up MySQL and Springboot application (this application) by `docker-compose`
21+
- Spin up Database and Springboot application (this application) by `docker-compose`
2222

2323
## Development
2424
```bash
@@ -27,7 +27,7 @@ $ make devBoot
2727
```
2828
`application-local.yml` will be referred for the configuration.
2929

30-
`make devDB` only spins up MySQL, and `make devBoot` run this application by development mode via `gradle`.
30+
`make devDB` only spins up Database, and `make devBoot` run this application by development mode via `gradle`.
3131

3232
### How to run test
3333
```bash

build.gradle.kts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repositories {
2121
}
2222

2323
extra["kotestVersion"] = "5.9.1"
24-
extra["openAPIVersion"] = "1.8.0"
24+
extra["openAPIVersion"] = "2.8.4"
2525
extra["testcontainersVersion"] = "1.20.4"
2626
extra["coroutinesCoreVersion"] = "1.10.1"
2727

@@ -44,15 +44,15 @@ dependencies {
4444
annotationProcessor("org.projectlombok:lombok")
4545

4646
// OpenAPI
47-
implementation("org.springdoc:springdoc-openapi-kotlin:${property("openAPIVersion")}")
48-
implementation("org.springdoc:springdoc-openapi-webflux-ui:${property("openAPIVersion")}")
47+
implementation("org.springframework.cloud:spring-cloud-function-web:4.2.1")
48+
implementation("org.springdoc:springdoc-openapi-starter-webflux-ui:${property("openAPIVersion")}")
49+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
4950

5051
// Database
51-
implementation("io.asyncer:r2dbc-mysql:1.3.1")
5252
implementation("io.r2dbc:r2dbc-pool:1.0.2.RELEASE")
53-
runtimeOnly("com.mysql:mysql-connector-j:8.4.+")
5453
implementation("org.springframework.data:spring-data-commons")
5554
implementation("org.springframework.data:spring-data-relational")
55+
implementation("org.postgresql:r2dbc-postgresql:1.0.7.RELEASE")
5656

5757
// Test
5858
testImplementation("io.kotest:kotest-runner-junit5:${property("kotestVersion")}")
@@ -64,9 +64,9 @@ dependencies {
6464
testImplementation("org.springframework.boot:spring-boot-starter-test")
6565
testImplementation("org.springframework.boot:spring-boot-testcontainers")
6666
testImplementation("io.projectreactor:reactor-test")
67-
testImplementation("org.testcontainers:junit-jupiter:1.17.3")
68-
testImplementation("org.testcontainers:mysql:1.17.3")
69-
testImplementation("org.testcontainers:r2dbc")
67+
testImplementation("org.testcontainers:junit-jupiter:${property("testcontainersVersion")}")
68+
testImplementation("org.testcontainers:postgresql:${property("testcontainersVersion")}")
69+
testImplementation("org.testcontainers:r2dbc:${property("testcontainersVersion")}")
7070

7171
// Faker
7272
implementation("net.datafaker:datafaker:1.8.1")

db/my.cnf

Lines changed: 0 additions & 15 deletions
This file was deleted.

db/mysql_init/01-databases.sql

Lines changed: 0 additions & 2 deletions
This file was deleted.

db/postgres_init/01-databases.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- データベースを作成
2+
CREATE DATABASE test
3+
WITH ENCODING 'UTF8';

docker-compose-local.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
services:
2-
mysql:
3-
image: mysql:8.0
4-
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2+
postgres:
3+
image: postgres:15
4+
environment:
5+
POSTGRES_USER: test
6+
POSTGRES_PASSWORD: password
7+
POSTGRES_DB: test
58
ports:
6-
- "3306:3306"
7-
- "33060:33060"
9+
- "5432:5432"
810
volumes:
9-
# Data initialize script trigger directory. place initialize file under the mysql_init directory.
10-
- ./db/mysql_init:/docker-entrypoint-initdb.d
11-
# persistent data directory
12-
- ./db/mysql_data:/var/lib/mysql
13-
# configuration file
14-
- ./db/my.cnf:/etc/mysql/conf.d/my.cnf
15-
environment:
16-
MYSQL_ROOT_PASSWORD: password
17-
MYSQL_USER: test
18-
MYSQL_PASSWORD: password
11+
- ./db/postgres_data:/var/lib/postgresql/data
12+
- ./db/postgres_init:/docker-entrypoint-initdb.d
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U test"]
15+
interval: 30s
16+
timeout: 10s
17+
retries: 5

docker-compose.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
services:
2-
mysql:
3-
image: mysql:8.0
4-
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
5-
healthcheck:
6-
test: "exit 0"
7-
2+
postgres:
3+
image: postgres:15
4+
environment:
5+
POSTGRES_USER: test
6+
POSTGRES_PASSWORD: password
7+
POSTGRES_DB: test
88
ports:
9-
- "3306:3306"
10-
- "33060:33060"
9+
- "5432:5432"
1110
volumes:
12-
# Data initialize script trigger directory. place initialize file under the mysql_init directory.
13-
- ./db/mysql_init:/docker-entrypoint-initdb.d
14-
# persistent data directory
15-
- ./db/mysql_data:/var/lib/mysql
16-
# configuration file
17-
- ./db/my.cnf:/etc/mysql/conf.d/my.cnf
18-
environment:
19-
MYSQL_ROOT_PASSWORD: password
20-
MYSQL_USER: test
21-
MYSQL_PASSWORD: password
11+
- ./db/postgres_data:/var/lib/postgresql/data
12+
- ./db/postgres_init:/docker-entrypoint-initdb.d
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U test"]
15+
interval: 30s
16+
timeout: 10s
17+
retries: 5
2218

2319
app:
2420
build:
@@ -28,5 +24,5 @@ services:
2824
- "8080:8080"
2925
- "9090:9090"
3026
depends_on:
31-
mysql:
27+
postgres:
3228
condition: service_healthy

0 commit comments

Comments
 (0)