过去我使用Slick访问服务器中的Vertica数据库。我最近将我的Slick版本从2.0升级到3.1。自升级以来,我遇到了一个错误(下面的堆栈跟踪)。该错误表示找不到光滑的驱动程序。
根据 Slick 3.2.1 docs,“可以使用缩减的功能集立即访问其他SQL数据库”。
我想知道的是 - 是否仍然可以使用光滑直接支持的“其他”类型的数据库?如果是这样,怎么样?
我的数据库配置是:
slick.dbs.default.driver="slick.driver.JdbcDriver"
slick.dbs.default.db.driver="com.vertica.jdbc.Driver"
slick.dbs.default.db.url=${some.url}
slick.dbs.default.db.user=${some.user}
slick.dbs.default.db.password=${some.pw}
请注意,感谢this Stack Overflow response,我还尝试了以下各项来替换配置中的第一行:
slick.dbs.default.driver="slick.driver.JdbcDriver$"
slick.dbs.default.driver="slick.driver.JdbcDriver$class"
slick.dbs.default.driver=slick.driver.JdbcDriver
我也在我的sbt文件中:
libraryDependencies ++= Seq(
"com.vertica" % "vertica-jdbc" % "7.0.1",
"com.typesafe.play" %% "play-slick" % "2.0.0")
请注意,Play-slick使用光滑的3.1.0。
完整堆栈跟踪:
[ERROR] [10/07/2016 16:43:52.336] [p.a.d.s.DefaultSlickApi] [*] Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of Slick driver "slick.driver.JdbcDriver"
at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:65)
at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.create(SlickApi.scala:89)
at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get$lzycompute(SlickApi.scala:81)
at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get(SlickApi.scala:80)
at play.api.db.slick.DefaultSlickApi.dbConfig(SlickApi.scala:66)
at play.api.db.slick.NamedDatabaseConfigProvider$$anon$1.get(SlickModule.scala:59)
at utils.liger.DimensionMapper.<init>(DimensionMapper.scala:32)
at utils.liger.DimensionMapper$$FastClassByGuice$$1320fe73.newInstance(<generated>)
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:84)
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
at play.core.server.ProdServerStart.main(ProdServerStart.scala)
Caused by: java.lang.InstantiationException: slick.driver.JdbcDriver
at java.lang.Class.newInstance(Class.java:427)
at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:63)
... 36 common frames omitted
Caused by: java.lang.NoSuchMethodException: slick.driver.JdbcDriver.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 37 common frames omitted
如果我改为使用:
slick.dbs.default.driver="slick.driver.JdbcDriver$"
然后:
[ERROR] [10/07/2016 16:36:07.701] [p.a.d.s.DefaultSlickApi] [*] Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of Slick driver "slick.driver.JdbcDriver$"
at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:65)
at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.create(SlickApi.scala:89)
at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get$lzycompute(SlickApi.scala:81)
at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get(SlickApi.scala:80)
at play.api.db.slick.DefaultSlickApi.dbConfig(SlickApi.scala:66)
at play.api.db.slick.NamedDatabaseConfigProvider$$anon$1.get(SlickModule.scala:59)
at controllers.liger.AwdAutomation.<init>(AwdAutomation.scala:43)
at controllers.liger.AwdAutomation$$FastClassByGuice$$64e5b177.newInstance(<generated>)
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
at scala.Option.fold(Option.scala:158)
at play.api.inject.RoutesProvider.get$lzycompute(BuiltinModule.scala:82)
at play.api.inject.RoutesProvider.get(BuiltinModule.scala:78)
at play.api.inject.RoutesProvider.get(BuiltinModule.scala:77)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:84)
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
at play.core.server.ProdServerStart.main(ProdServerStart.scala)
Caused by: java.lang.ClassNotFoundException: slick.driver.JdbcDriver$
at java.lang.ClassLoader.findClass(ClassLoader.java:530)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at slick.util.ClassLoaderUtil$$anon$1.loadClass(ClassLoaderUtil.scala:12)
at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:62)
... 78 common frames omitted
答案 0 :(得分:0)
使用Slick 3.0时,不推荐使用通用jdbc驱动程序slick.driver.JdbcDriver$
(正如您从source看到的那样),然后在版本3.1中删除(这解释了您看到的错误)< / p>
到目前为止,通过光滑的3.2,可以通过特征slick.jdbc.JdbcProfile的自定义实现支持其他数据库