我有一个这样的对象:
object DatabaseFactory {
import slick.jdbc.PostgresProfile.api._
private val db = Database.forConfig("database.postgresql")
def getDatabase = db
}
以及类似的配置:
database {
postgresql {
connectionPool = "HikariCP"
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
properties = {
serverName = "localhost"
portNumber = "5432"
databaseName = "myProject"
user = "user"
password = "userPass"
}
numThreads = 10
}
}
有任何方法可以从slick获取javax.sql.DataSource吗?我需要一个来自slick的PGSimpleDataSource实例。
我想在Flyway配置上使用它:
Flyway.configure()
.baselineOnMigrate(true)
.locations("filesystem:/etc/myProject/db-scripts")
.dataSource(??? Need DataSource ???)
我刚刚偶然发现了这一点,并看到了https://stackoverflow.com/users/337134/knows-not-much的评论。基本上,您需要实现自己的数据源实例: