LoginSignup
0
0

More than 1 year has passed since last update.

Spring 案件ソルーション3 Validation 手順書フォルダ

Last updated at Posted at 2021-05-23

背景 

Springの機能を確認したかった。
特にValidationを一旦なんとかしておきたいなと思っています。

やって見て・・・

9 Spring Security → 一旦パス
10 Spring Test→ テスト強化の時にやりたいと思います。

リソース

Spring Boot 2 入門: 基礎から実演まで 原田 けいと https://www.amazon.co.jp/dp/B0893LQ5KY/ref=cm_sw_r_tw_dp_BV9D710FBKGWDJJJ3NF9

TakeAway

ちゃんと想定通りのJavaバージョンになっているか。

Javaの環境設定
コンパイラー

lombokの設定

1.サイトからlombok.jarをダウンロードする。

2.⁨⁨/Applications/SpringToolSuite4.app/Contents/Eclipse/へlombok.jarを配置する。

3./Applications/SpringToolSuite4.app/Contents/Eclipse/SpringToolSuite4.iniへ下記を追記する。
-javaagent:/Applications/SpringToolSuite4.app/Contents/Eclipse/lombok.jar
4.STSを再起動する

Validation

1stStep

まずはここから
https://itsakura.com/java-springboot-validate
公式
https://spring.pleiades.io/guides/gs/validating-form-input/

2ndStep

主要クラス・ファイル

WebConfig
SignupController
GroupOrder
ValidGroup1
ValidGroup2
ValidGroup3
SignupForm
signup.html
messages.properties
pom.xml

ログについて

ログ設定

lombok 設定必要
@Slf4j
→ アノテーション必要。

ログのレベルを変えたい。→

application.properties に
logging.level.<パッケージ名>や<クラス名>を追加
logging.level.com.example.demo=trace

パスの指定

logging.file.path=./log

ファイル名の指定

logging.file.name=./log/application.log
参考アドレス
https://github.com/noikedan/SpringSample/tree/master/SpringSample
参考書籍 
https://www.amazon.co.jp/dp/B07H6XLXD7/ref=cm_sw_r_tw_dp_9RV3PNQ8RNPWFZ0Y1QJM
参考アドレス
https://docs.jboss.org/hibernate/validator/6.1/reference/en-US/html_single/#validator-defineconstraints-spec

AOP

参考アドレス
https://qiita.com/daisuzz/items/de937816a5d7c9210469
https://github.com/noikedan/search

Testのやり方

@SpringBootTest・・・SpringBootの機能を有効にします。
@Transactional・・・テスト開始から終了までを、トランザクション処理にします。これを付けると、各テスト後に、データが初期化(ロールバック)されます。

自作サービス

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0