Created
January 31, 2012 09:23
-
-
Save mumoshu/1709603 to your computer and use it in GitHub Desktop.
Run Play 2.0 app from Play console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks! | |
// http://voidy21.hatenablog.jp/entry/2012/01/09/024544 | |
// | |
// Usage: | |
// Run `play console` and then :paste the below code | |
// | |
// Tested on commit 4727620693 of Play20 master, at Feb 6. | |
// | |
// Follow the below steps to enable play.api.test classes in Play console. | |
// $ set libraryDependencies += "play" %% "play-test" % "2.0-RC1-SNAPSHOT" | |
// $ console | |
import play.api.Application | |
import play.api.Play | |
import play.api.db.evolutions.OfflineEvolutions | |
import play.api.Mode | |
val appBase = new java.io.File(".") | |
lazy val classLoader = | |
Thread.currentThread.getContextClassLoader | |
val databases = List("default"/*, "mysql"*/) | |
for (db <- databases) { | |
OfflineEvolutions.applyScript(classLoader, db) | |
} | |
val application = | |
new Application(appBase, classLoader, None, Mode.Dev) | |
Play.start(application) | |
import play.api.Play.current | |
import models._ | |
// test your model code | |
import controllers._ | |
// test you controller code | |
// import play.api.test._ | |
// import play.api.test.Helpers._ | |
// contentAsString(controllers.Application.index(play.api.test.FakeRequest())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
こんなエラーが出たら、application.conf で default などの DB設定を記述し忘れているかも?