要重现该错误,请找到play-slick-todos。
我遵循play-slick-sample中的模式,使用Playframework和Slick实现待办事项列表API端点。为简化此问题,我仅实现了index
端点。
完成sbt run
后,访问localhost:9000
到达index
中的Application
端点。但是,它引发以下错误:
[error] application -
! @797hp92i6 - Internal server error, for (GET) [/] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[JdbcSQLException: Table "todo" not found; SQL statement:
select "id", "content" from "todo" [42102-197]]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:251)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:178)
at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:363)
at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:361)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:413)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
Caused by: org.h2.jdbc.JdbcSQLException: Table "todo" not found; SQL statement:
select "id", "content" from "todo" [42102-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.Parser.readTableOrView(Parser.java:5920)
at org.h2.command.Parser.readTableFilter(Parser.java:1430)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:2138)
at org.h2.command.Parser.parseSelectSimple(Parser.java:2287)
at org.h2.command.Parser.parseSelectSub(Parser.java:2133)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1946)
at org.h2.command.Parser.parseSelect(Parser.java:1919)
似乎Slick不会为我创建“ todo”表。
我知道如何创建表:对于todos,Await.result(db.run(todos.schema.create))
可以完成工作。但是我不知道将它们放在哪里,我相信这应该由Slick and Play完成。
感谢您的帮助。谢谢!
versions:
play - 2.6.18
scala - 2.12.6
h2 - 1.4.197
play-slick - 3.0.1
play-slick-evolutions - 3.0.1