首页 > 解决方案 > 运行服务器后播放应用程序意外异常

问题描述

我有一个用于简单 CRUD 操作的 scala play 应用程序。我能够运行这个应用程序并用它进行了大量的测试。但是,现在当我尝试运行该应用程序时,服务器已启动,但无法接受任何 http 请求并突然失败。

我尝试运行以下命令

clean
compile
update
reload

并且它们都成功执行。当我使用run命令运行服务器时,我在控制台上得到一个输出为

[IJ][user-service] $ run

--- (Running the application, auto-reloading is enabled) ---

[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Enter to stop and go back to the console...)

现在,只要我发出任何 http 请求(之前工作过),我就会收到以下错误。

[error] application - 

! @7bag02h83 - Internal server error, for (GET) [/service/api/setup] ->

play.api.UnexpectedException: Unexpected exception[IllegalArgumentException: requirement failed: sourceMapper parameter is no longer supported by createContext; use create method's devContext parameter instead]
    at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:186)
    at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
    at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:202)
    at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:117)
    at akka.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1318)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:519)
    at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:482)
    at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:378)
    at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:588)
    at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:472)
Caused by: java.lang.IllegalArgumentException: requirement failed: sourceMapper parameter is no longer supported by createContext; use create method's devContext parameter instead
    at scala.Predef$.require(Predef.scala:277)
    at play.api.ApplicationLoader$.createContext(ApplicationLoader.scala:187)
    at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:172)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
    at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:171)
    at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
    at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:202)
    at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:117)
    at akka.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1318)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:519)
[error] application 

谁能让我知道我在这里缺少什么?是否需要添加某种配置设置?

任何指针都会非常有帮助。提前致谢 !!!

标签: scalaserverplayframework

解决方案


我恢复了 build.sbt 文件的依赖项,它现在似乎可以工作了。

当前 build.sbt (正在工作)

libraryDependencies += guice
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.3"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.3"

libraryDependencies += "com.h2database" % "h2" % "1.4.196"

libraryDependencies += specs2 % Test

旧 build.sbt (这给了我错误)

libraryDependencies ++= Seq(
  guice,
  ws,
  "com.typesafe.play" %% "play-slick" % "4.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "4.0.0",
  "com.h2database" % "h2" % "1.4.197",
  specs2 % Test
)

我不知道它是如何重新开始工作的,但解决了我的问题。谢谢 !!!


推荐阅读