LoginSignup
0
0

SpringBootでとにかく最低限のログイン機能追加

Last updated at Posted at 2024-04-23

この記事はこれの続きです

概要

とにかく最小限のコーディング。
ユーザーIDとパスワードはSpringBootが用意した固定値。
ユーザーIDとパスワード入力画面も自作しない。

という最低限のログインができることろまでの内容です。

build.gradle

dependencies セクションに下記を追記します。

implementation 'org.springframework.boot:spring-boot-starter-security'

build.gradleを変更したら下記を忘れずに。
image.png

これだけでSpringBootがいろいろ用意してくれます。

動作確認

SpringBootを起動すると「固定のパスワードはこれだよ」的なログが出力されます。
image.png

ブラウザーでSpringBootのURLにアクセスするとログイン画面になります。
この画面はSpringBootが勝手に用意してくれたものです。
image.png

ユーザーIDは『user』固定。
パスワードはログに出力されていた文字列です。

この記事の続き

バージョン

Microsoft Windows [Version 10.0.22631.3447]
JAVA 17.0.10
Spring Boot v3.1.10

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