Skip to content

miyabayt/spring-boot-r2dbc-thymeleaf-sample

Repository files navigation

Spring Boot R2DBC Thymeleaf Sample Application

開発環境(IntelliJ)の推奨設定

  • bootRunを実行している場合でもビルドされるようにする。(単一ファイルのビルドを実行すると spring-devtools が変更を検知して自動的に再起動されるようになります)
    • Intellij > Ctrl+Shift+A > type Registry... > compiler.automake.allow.when.app.runningをONにする。
  • Windowsの場合は、コンソール出力が文字化けするため、C:¥Program Files¥JetBrains¥IntelliJ Idea xx.x.x¥binの中にあるidea64.exe.vmoptions ファイルに-Dfile.encoding=UTF-8を追記する。
  • ブラウザにLiveReload機能拡張をインストールする。

Docker

$ ./gradlew composeUp

minikube

on MacOS

$ # starts a local Kubernetes cluster
$ minikube start --vm-driver="hyperkit"

$ # configure environment to use minikube’s Docker daemon
$ eval $(minikube -p minikube docker-env)

$ # enable a minikube addon
$ minikube addons enable ingress

$ # redis / mysql / mailhog
$ kubectl apply -f k8s

on Windows10 pro

C:\> minikube start --vm-driver="hyperv"
C:\> minikube docker-env --shell powershell | Invoke-Expression
C:\> minikube addons enable ingress
C:\> kubectl apply -f k8s

set External URL

minikubeのIPアドレスを確認して、gradle.propertiesに設定する

$ minikube ip
192.168.64.3

$ vi gradle.properties
---
# set nip.io domain with minikube ip
jkube.domain=192.168.64.3.nip.io
---

Build & Apply

$ # delete old service
$ ./gradlew k8sUndeploy

$ # apply new service
$ ./gradlew clean k8sApply

$ # check pod, svc
$ kubectl get all

$ # tail the log
$ ./gradlew k8sLog

Check running

$ # check the ingress resource
$ kubectl get ingress
NAME                                 CLASS   HOSTS                                                    ADDRESS        PORTS   AGE
spring-boot-r2dbc-thymeleaf-sample   nginx   spring-boot-r2dbc-thymeleaf-sample.192.168.64.3.nip.io   192.168.64.3   80      11m

$ # send a request
$ curl http://spring-boot-r2dbc-thymeleaf-sample.192.168.64.3.nip.io/actuator/health
{"status":"UP","groups":["liveness","readiness"]}

動作確認

ブラウザでの動作確認

URL http://spring-boot-r2dbc-thymeleaf-sample.192.168.64.3.nip.io
メールアドレス test@example.com
パスワード passw0rd

データベースの確認

mysql -h 192.168.64.3 -P 30306 -uroot -ppassw0rd spring-boot-r2dbc-thymeleaf-sample

mysql> show tables;
+----------------------------------------------+
| Tables_in_spring-boot-r2dbc-thymeleaf-sample |
+----------------------------------------------+
| code_categories                              |
| codes                                        |
| flyway_schema_history                        |
| holidays                                     |
| mail_templates                               |
| permissions                                  |
| role_permissions                             |
| roles                                        |
| send_mail_queue                              |
| staff_roles                                  |
| staffs                                       |
| upload_files                                 |
| user_roles                                   |
| users                                        |
+----------------------------------------------+
14 rows in set (0.01 sec)

メールの確認

http://192.168.64.3:30825

参考情報

プロジェクト 概要
JKube k8sへのデプロイを簡略化するプラグイン
Lombok Project 定型的なコードを書かなくてもよくする
Springframework Spring Framework(Spring WebFlux)
Spring Security セキュリティ対策、認証・認可のフレームワーク
Project Reactor リアクティブプログラミングのためのライブラリ
Spring Data R2DBC Reactive O/Rマッパー
Flyway DBマイグレーションツール
Thymeleaf テンプレートエンジン
Thymeleaf Layout Dialect テンプレートをレイアウト化する
AdminLTE 管理画面テンプレート
WebJars jQueryなどのクライアント側ライブラリをJARとして組み込む
ModelMapper Beanマッピングライブラリ
JUnit5 テストフレームワーク
Mockito モッキングフレームワーク
MailHog ウェブベースのSMTPテスター

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •