Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
20
Help us understand the problem. What is going on with this article?
@TomoyaIgarashi

play test 実行時に指定したconfファイルを読み込む

More than 5 years have passed since last update.

環境

  • Mac OSX Version 10.8.5
  • Play Framework 2.2.1

手順

conf/以下にtest.confを作る。

shell
$ touch conf/test.conf

test.confにてapplication.confを読み込み、上書きしたい設定を記述する。

shell
$ vi conf/test.conf
include "application.conf"

db.default.url="jdbc:mysql://database.localdomain/test_database" 

build.sbtのjavaOptionsにテスト環境の時に読み込むconfファイルを指定する。

shell
$ vi build.sbt
javaOptions in Test += "-Dconfig.file=conf/test.conf"

参考

コマンドラインで$ play -Dconfig.file=test.conf testとしても読み込まれなかったので、以下サイトを参考にして読み込まれるようにした。

20
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
20
Help us understand the problem. What is going on with this article?