特別是,對於測試用例,我希望保持測試數據庫的獨立性,以便測試用例不會干擾開發或生產數據庫。如何在Play中保留獨立的開發,測試和產品數據庫! 2框架?
什麼是分離開發,測試和生產環境的良好實踐?
EDIT1:有些情況下
在Ruby on Rails的,有按照慣例不同的環境不同的配置文件。 Play也是如此! 2還支持?
或者,我必須煮配置文件,然後編寫一些粘合代碼,選擇適當的配置文件?
目前如果我運行sbt test
它使用開發數據庫(在conf/application.conf中配置爲「default」)。不過,我希望Play!2使用不同的測試數據庫。
EDIT2:在那玩提供的命令
對於玩遊戲! 2框架,我觀察到了這一點。
$ help play
Welcome to Play 2.2.2!
These commands are available:
-----------------------------
...OUTPUT SKIPPED...
run <port> Run the current application in DEV mode.
test Run Junit tests and/or Specs from the command line
start <port> Start the current application in another JVM in PROD mode.
...OUTPUT SKIPPED...
有三個爲「測試」,「發展」和「生產」的情況下,這是明確的命令:
test
:此運行測試用例。所以它應該自動選擇test
配置。run <port>
:在指定的port
上運行development
實例。所以這個命令應該自動選擇development
配置。start <port>
:這將在指定的port
上運行production
實例。所以這應該自動選擇production
配置。
但是,所有這些命令都會選擇conf/application.conf
中提供的值。我覺得在這裏可以填補一些空白。
如果我錯了,請糾正我。
EDIT3:最好的辦法是使用Global.scala
說明如下:How to manage application.conf in several environments with play 2.0?
不同的配置文件?你的問題有點過於通用。 – vptheron
我剛剛更新了「某些上下文」的問題。 – tuxdna
雖然你的編輯已經幫助澄清你正在尋找這個問題現在看起來更像是一個重複http://stackoverflow.com/questions/10391987/how-to-set-up-different-databases-per-環境在發揮2-0 – Exupery