我可以使用play的default.db连接:
db.default.driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
db.default.url="jdbc:sqlserver://my_host.database.windows.net:1433;database=my_db;"
db.default.username="username"
db.default.password="password"
但是当我尝试使用Slick时:
slick.dbs.default {
driver = "com.typesafe.slick.driver.ms.SQLServerDriver$"
db {
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
url = "jdbc:sqlserver://my_host.database.windows.net:1433;database=my_db;"
user = "username"
password = "password"
}
}
我明白了:
ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.NoClassDefFoundError: slick/profile/RelationalProfile$SimpleQL
指向我的DAO:
import play.api.db.slick.DatabaseConfigProvider
class UsersDAO @Inject() (override protected val dbConfigProvider: DatabaseConfigProvider) extends Tables(dbConfigProvider) { // <---- This line
...
}
这是我的Tables.scala文件:
import models.User
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.driver.JdbcProfile
class Tables @Inject() (protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
protected val users = TableQuery[Users]
protected class Users(tag: Tag) extends Table[User](tag, "users") {
def id = column[String]("id", O.PrimaryKey)
def firstName = column[String]("first_name")
def lastName = column[String]("last_name")
def * = (id, firstName, lastName) <> ((User.apply _).tupled, User.unapply _)
}
}
以下是我build.sbt
文件中的相关行:
libraryDependencies ++= Seq(
...
"com.typesafe.play" % "play-slick_2.11" % "2.0.2",
"com.typesafe.slick" %% "slick-extensions" % "3.0.0",
...
)
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/maven-releases/"
我无法找到有关SimpleQL
的任何内容以及运行时遗漏的原因。
答案 0 :(得分:0)
play-slick 2.0.2使用光滑的3.1.0,因此您必须在光滑扩展中匹配此版本:
libraryDependencies ++= Seq(
...
"com.typesafe.play" % "play-slick_2.11" % "2.0.2",
"com.typesafe.slick" %% "slick-extensions" % "3.1.0",
...
)