我成功下载并成功运行了项目here,但在升级到Play 2.5.3后它又崩溃了。有帮助吗?错误发生在最后一条指令
上package controllers
import javax.inject._
import play.api._
import play.api.http._
import play.api.mvc._
import play.twirl.api.Html
import java.io.FileReader
import javax.script.ScriptEngineManager
@Singleton
class HomeController @Inject()(webJarAssets: WebJarAssets) extends Controller {
/**
* Create an Action to render an HTML page with a welcome message.
* The configuration in the `routes` file means that this method
* will be called when the application receives a `GET` request with
* a path of `/`.
*/
def index2 = Action {
Ok(views.html.index("Your new application is ready.",webJarAssets))
}
def index = Action {
// Pass 'null' to force the correct class loader. Without passing any param,
// the "nashorn" JavaScript engine is not found by the `ScriptEngineManager`.
//
// See: https://github.com/playframework/playframework/issues/2532
val engine = new ScriptEngineManager(null).getEngineByName("nashorn")
if (engine == null) {
BadRequest("Nashorn script engine not found. Are you using JDK 8?")
} else {
// React expects `window` or `global` to exist. Create a `global` pointing
// to Nashorn's context to give React a place to define its global
// namespace.
engine.eval("var global = this;")
// Define `console.log`, etc. to send messages to Nashorn's global `print`
// function so the messages are written to standard out.
engine.eval("var console = {error: print, log: print, warn: print};")
// Evaluate React and the application code.
engine.eval(new FileReader("target/web/web-modules/main/webjars/lib/react/react-with-addons.js"))
engine.eval(new FileReader("target/web/public/main/javascripts/components/App.js"))
Ok(views.html.main("React on Play",webJarAssets) {
play.twirl.api.Html(engine.eval("React.renderToString(React.createElement(App));").toString)
})
}
}
}