设置Play框架环境

时间:2015-11-23 16:03:41

标签: scala playframework

项目部署时遇到问题。到目前为止,我正在使用一个playframework应用程序,运行监听端口80。 现在,我已经在同一服务器上发布了2个应用程序,使用Nginx作为代理。 Nginx在端口80中侦听,应用程序在端口9001和9002中运行。

一切运行良好,但是应用程序在开发模式下运行而不是在prod模式下运行,页面404不起作用,在html页面中我看到代码错误如下:“找不到请求的动作'GET / asd “”。 我用这个命令运行应用程序:

myapp -Dhttp.port = 9001 -Dconfig.file = conf / application.conf -Dlogger.file = / mydir / conf / application-logger.xml -Dpidfile.path = / mydir / daasy.pid -server

我使用scala 2.11.7的playframework 2.4.3

更新 我创建了一个bootstrap类:

class onStartClass @Inject() (val app: Application)
{
  println(app.mode)
}

app.mode在prod中运行时返回“Prod”,端口80以及在端口9001中运行时。

但是,当在端口9001中运行的应用程序在页面404不起作用时,网站返回播放框架错误页面。

1 个答案:

答案 0 :(得分:0)

据我了解,您观察到的是Play 2.4的正确行为

在开发模式下,404由devNotFound.scala.html模板处理并产生错误,如下所示: enter image description here

在prod模式下,404由notFound.scala.html模板处理并产生错误,如下所示: enter image description here

注意第一个错误列出了所有现有路由,而第二个错误没有列出。

如果您想要另外渲染404 NotFound错误,则需要创建自己的错误处理程序,如ScalaErrorHandling

中所述