官方 Slick 3.2 文档
( http://slick.lightbend.com/doc/3.2.0/database.html )
说 Slick 可以用普通的 javax.sql.DataSource
配置,例如 PGSimpleDataSource
或 PPGoolingDataSource
:
val db = Database.forDataSource(dataSource: javax.sql.DataSource, Some(size: Int))
我找不到要导入的数据库
对象。
该数据库单例对象甚至不存在于官方 ScalaDoc 中: http://slick.lightbend.com/doc/3.2.0/api/index.html
我在我的 build.sbt
中包含以下依赖项。我是否缺少 slick-postgresql 绑定(bind)或某些其他依赖项,这些依赖项具有文档中指定的缺少 Database
对象?
"com.typesafe.slick" %% "slick" % "3.2.0"
"org.postgresql" % "postgresql" % "42.0.0"
最佳答案
Quick Intro部分说
// Use H2Profile to connect to an H2 database import slick.jdbc.H2Profile.api._
Since we are using H2 as our database system, we need to import features from Slick’s H2Profile. A profile’s api object contains all commonly needed imports from the profile and other parts of Slick such as database handling.
所以我相信你想导入 PostgresProfile
接口(interface):
import slick.jdbc.PostgresProfile.api._
关于postgresql - 使用 Postgresql 的 Slick 3.2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42495387/