2015-10-07 6 views
13

ich glatt zu meinem Stück Projekt einführen wollen, so dass ich fügen Sie die folgenden Abhängigkeiten build.sbt:A bis play.api.db.DBApi Bindung wurde bereits konfiguriert ist, Entwicklungen und Injektor Fehler mit Spiel-Slick

"com.typesafe.play"   %% "play-slick"    % "1.0.1"  withSources(), 
    "com.typesafe.play"   %% "play-slick-evolutions" % "1.0.1"  withSources(), 

Dann, wenn ich eine Integrationsspezifikation für den Controller ausführen, habe ich folgende Ausnahme sowohl auf Intellij IDE und Kommandozeilen-Aktivator-Test. Nachdem Google fand ich die Lösung: https://www.playframework.com/documentation/2.4.x/PlaySlickFAQ#A-binding-to-play.api.db.DBApi-was-already-configured

Nachdem ich die jdbc Abhängigkeit, die Integration spec bestanden entfernt, wenn ich über die Befehlszeile, jedoch habe ich immer noch den gleichen Fehler, wenn ich den Test auf IntelliJ IDE wie folgende Fehler ausgeführt: Ausnahme angetroffen werden, wenn Run auf einer verschachtelten Suite Aufruf - Unable Injektor zu schaffen, siehe die folgenden Fehler:

1) A binding to play.api.db.DBApi was already configured at play.api.db.DBModule.bindings(DBModule.scala:25): 
Binding(interface play.api.db.DBApi to ProviderConstructionTarget(class play.api.db.DBApiProvider)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1). 
    at play.api.db.slick.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:15): 
Binding(interface play.api.db.DBApi to ConstructionTarget(class play.api.db.slick.evolutions.internal.DBApiAdapter) in interface javax.inject.Singleton) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1) 

1 error 
com.google.inject.CreationException: Unable to create injector, see the following errors: 

1) A binding to play.api.db.DBApi was already configured at play.api.db.DBModule.bindings(DBModule.scala:25): 
Binding(interface play.api.db.DBApi to ProviderConstructionTarget(class play.api.db.DBApiProvider)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1). 
    at play.api.db.slick.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:15): 
Binding(interface play.api.db.DBApi to ConstructionTarget(class play.api.db.slick.evolutions.internal.DBApiAdapter) in interface javax.inject.Singleton) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1) 

1 error 
    at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466) 
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155) 
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107) 
    at com.google.inject.Guice.createInjector(Guice.java:96) 
    at com.google.inject.Guice.createInjector(Guice.java:73) 
    at com.google.inject.Guice.createInjector(Guice.java:62) 
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) 
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) 
    at play.api.test.FakeApplication.<init>(Fakes.scala:216) 
    at org.scalatestplus.play.OneServerPerSuite$class.app(OneServerPerSuite.scala:152) 

Antwort

4

Sie haben wahrscheinlich Abhängigkeit jdbc hinzugefügt, die keinen Sinn macht, wenn Sie es glatt verwenden. Entfernen Sie es und es wird funktionieren.

29

Wenn Sie wie ich sind, haben Sie so etwas in Ihrer build.sbt

libraryDependencies ++= Seq(
    jdbc, 
    cache, 
    ws, 
    specs2 % Test, 
    "mysql" % "mysql-connector-java" % "5.1.37", 
    "com.typesafe.play" %% "play-slick" % "1.1.1", 
    "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1" 
) 

entfernen jdbc

libraryDependencies ++= Seq(
    //jdbc, //<<---- this one here 
    cache, 
+0

Eigentlich gibt eine offizielle [FAQ] ist (https: // www .playframework.com/documentation/2.5.x/PlaySlickFAQ #A-binding-to-play.api.db.DBApiwurde bereits konfiguriert und beschreibt dieses Problem. –

Verwandte Themen