0
0

More than 3 years have passed since last update.

転職活動管理アプリを作ろう②(開発環境構築~ログイン画面)

Posted at

前回は コチラ

ツール

  • OS
    • Windows 10
  • IDE
    • eclipse (Version: 2020-12 (4.18.0))
      • [新規] > [Spring スターター・プロジェクト] より新規プロジェクトを作成
      • [ウィンドウ] > [ビューの表示] より「Bootダッシュボード」を開いておく
  • DB
    • MySQL (docker)
      • ココ に docker-compose を置きました
      • localhost:3306 で接続可能
      • http://localhost:8081/ で phpMyAdmin へ接続

プロジェクト設定

  • Spring Boot
    • 必要なモジュールは以下の通り
      • spring-boot-starter-data-jpa
      • spring-boot-starter-security
      • spring-boot-starter-thymeleaf
      • spring-boot-starter-web
      • spring-boot-starter-web-services
      • spring-session-core
      • thymeleaf-extras-springsecurity5
      • spring-boot-devtools
      • mysql-connector-java
      • spring-boot-starter-test
      • spring-security-test
      • spring-boot-starter-data-jdbc
      • spring-boot-starter-jdbc
  • application.properties

    • DB 接続に必要な設定は以下の通り

      spring.datasource.url=jdbc:mysql://localhost:3306/sample
      spring.datasource.username=test
      spring.datasource.password=tset
      spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
      # spring.sql.init.mode=always
      # spring.sql.init.schema-locations=classpath:database/schema.sql
      # spring.sql.init.data-locations=classpath:database/data.sql
      spring.sql.init.encoding=utf-8
      

ログイン画面表示

  1. $ docker-compose up -d で MySQL コンテナ(および phpMyAdmin コンテナ)を起動する
  2. 「Bootダッシュボード」より対象のプロジェクトを右クリック > [(再)起動] を選択
  3. http://localhost:8080/ にアクセスするとログイン画面が表示される

次回に向けて

  • docker(≒ dockerhub)を使うことで MySQL 環境構築がすぐ出来た
  • Spring Boot が Tomcat を内包してくれているので、eclipse にプラグインを入れずともサーバー起動可能なことに感動した
    • Linux 環境へのデプロイ方法や環境構築については後々調査する
  • spring-boot-starter-security モジュールを入れることでログイン画面が即表示できた
    • DB のスキーマ定義、実際のログイン処理については後々調査する
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