使用 Postgresql 的 Slick 3.2?

Slick 3.2 with Postgresql?

Slick 3.2 官方文档 (http://slick.lightbend.com/doc/3.2.0/database.html) 说 Slick 可以配置为正常的 javax.sql.DataSource,例如 PGSimpleDataSourcePGPoolingDataSource

val db = Database.forDataSource(dataSource: javax.sql.DataSource, Some(size: Int))

我找不到要导入的 Database 对象。

该数据库单例对象甚至不存在于官方 ScalaDoc 中: http://slick.lightbend.com/doc/3.2.0/api/index.html

我在 build.sbt 中包含以下依赖项。我是否缺少 slick-postgresql 绑定或某些其他依赖项,这些依赖项具有文档中指定的缺失 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 api:

import slick.jdbc.PostgresProfile.api._