播放演变是否与Slick一起使用(或者只是玩游戏)

时间:2016-01-20 05:09:03

标签: scala playframework slick slick-3.0 playframework-evolutions

我们使用play-slick遇到了一堆problems,所以我已经恢复了直接的Slick 3.1.1实施。

这解决了我们在并发方面的各种问题,但是......现在我试图添加进化,但它似乎并没有起作用。我已将以下内容添加到build.sbt

libraryDependencies ++= Seq( "com.typesafe.slick" %% "slick" % "3.1.1", "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1", ...

而且,当我这样做的时候,我注意到了#34; play-slick-evolutions"并且思考,"哦,不,我敢打赌那些只有play-slick。"似乎是这种情况,因为演变解雇。

当我尝试打开它时,我会遇到以下例外情况:

[error]   ! work from within a browser
[error]    com.google.inject.CreationException: Unable to create injector, see the following errors:
[error]
[error]    1) No implementation for play.api.db.DBApi was bound.
[error]      while locating play.api.db.DBApi
[error]        for parameter 3 at play.api.db.evolutions.ApplicationEvolutionsProvider.<init>(EvolutionsModule.scala:45)
[error]      at play.api.db.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:22):
[error]    Binding(class play.api.db.evolutions.ApplicationEvolutions to ProviderConstructionTarget(class play.api.db.evolutions.ApplicationEvolutionsProvider) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
[error]
[error]    2) No implementation for play.api.db.DBApi was bound.
[error]      while locating play.api.db.DBApi
[error]        for parameter 0 at play.api.db.evolutions.DefaultEvolutionsApi.<init>(EvolutionsApi.scala:71)
[error]      at play.api.db.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:21):
[error]    Binding(interface play.api.db.evolutions.EvolutionsApi to ConstructionTarget(class play.api.db.evolutions.DefaultEvolutionsApi)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
[error]
[error]    2 errors (Errors.java:466)
[error] com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466)
[error] com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
[error] com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
[error] com.google.inject.Guice.createInjector(Guice.java:96)
[error] com.google.inject.Guice.createInjector(Guice.java:73)
[error] com.google.inject.Guice.createInjector(Guice.java:62)
[error] play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
[error] play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
[error] play.api.test.FakeApplication.<init>(Fakes.scala:216)
[error] play.api.test.WithBrowser$.$lessinit$greater$default$2(Specs.scala:74)
[error] application.TestBrowserResponses$$anonfun$1$$anonfun$apply$1$$anon$1.<init>(TestBrowserResponses.scala:8)
[error] application.TestBrowserResponses$$anonfun$1$$anonfun$apply$1.apply(TestBrowserResponses.scala:8)
[error] application.TestBrowserResponses$$anonfun$1$$anonfun$apply$1.apply(TestBrowserResponses.scala:8)

任何人都知道是否可以使用简单的Slick进行演化?

2 个答案:

答案 0 :(得分:1)

是的,Evolutions可以与普通Slick一起使用而不使用play-slick

您可以使用

添加依赖项
libraryDependencies += evolutions

另外,请确保play.evolutions.enabled中的false未设置为application.conf以触发演变。

  

如果配置了数据库,则会自动激活Evolutions   application.conf和evolution脚本存在。

有关详细信息,请参阅Evolutions documentation

<强>更新 关于您获得的例外情况。请参阅此文档。 https://www.playframework.com/documentation/2.4.x/PlaySlickFAQ#A-binding-to-play.api.db.DBApi-was-already-configured

答案 1 :(得分:0)

您可能必须将您的sql app特定的jdbc驱动程序添加到build.sbt,因为光滑的没有它。例如:

libraryDependencies ++= Seq(
  "org.xerial" % "sqlite-jdbc" % "3.8.11.2",
  "com.typesafe.play" %% "play-slick" % "2.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "2.0.0"
)