我这两天试图运行使用油滑3.1.1普通SQL查询,我跟着入门和数据库配置指南。
问题是,当代码编译正确,它忽略我的数据库参数(在配置的那些是错的),它打印此到stdout(虽然它应该抛出一个异常):
HikariCP pool database is starting.
List()
这里是我的测试代码:
import slick.driver.PostgresDriver.api._
import scala.concurrent.ExecutionContext.Implicits.global
object app extends App {
doit
def doit {
val db = Database.forConfig("mydb")
val result = db.run( sql"SELECT NOW()".as[String] )
println(result)
}
}
这里是“application.conf”
mydb = {
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
properties = {
databaseName = "mydb"
user = "myuser"
password = "secret"
}
numThreads = 10
}
这里是“build.sbt”
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "9.4.1208",
"mysql" % "mysql-connector-java" % "5.1.35",
"com.typesafe.slick" %% "slick" % "3.1.1",
"com.typesafe.slick" %% "slick-hikaricp" % "3.1.1",
"com.zaxxer" % "HikariCP" % "2.4.7"
)
另外,我有斯卡拉“2.11.8”。