ユーザ用ツール

サイト用ツール


java:playframework:createmodel

文書の過去の版を表示しています。


Java - Play Framework

モデルの作成

プロジェクト作成時にはmodelsパッケージが作成されないため、
データベースを使用する場合は手動で用意する必要があります。
その後、modelsパッケージ内に必要なモデルクラスを作成していきます。

設定ファイルへの定義

各環境設定ファイルにデータベース使用に関わる設定を追加します。

project/plugins.sbt

addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.1.0")

conf/application.conf

# This is the main configuration file for the application.
# https://www.playframework.com/documentation/latest/ConfigFile

play.modules {
  enabled += "play.api.db.DBModule"
}

play.db {
  config = "db"
  default = "default"

  # Play uses HikariCP as the default connection pool.  You can override
  # settings by changing the prototype:
  prototype {
    # Sets a fixed JDBC connection pool size of 50
    hikaricp.minimumIdle = 50
    hikaricp.maximumPoolSize = 50
  }
}

db {
  default.driver = com.mysql.jdbc.Driver
  default.url = "jdbc:mysql://[IP or Hostname]/[Database]?characterEncoding=UTF8"
  default.username = [Username]
  default.password = [Password]
}

ebean.default = ["models.*"]

java/playframework/createmodel.1532415477.txt.gz · 最終更新: 2018/07/24 15:57 by taka