NoClassDefFoundError: slick/profile/RelationalProfile$SimpleQL
NoClassDefFoundError: slick/profile/RelationalProfile$SimpleQL
我可以使用游戏的 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
的任何信息,也找不到它在 运行 时丢失的原因。
play-slick 2.0.2 使用 slick 3.1.0 所以你必须在 slick-extensions 中匹配这个版本:
libraryDependencies ++= Seq(
...
"com.typesafe.play" % "play-slick_2.11" % "2.0.2",
"com.typesafe.slick" %% "slick-extensions" % "3.1.0",
...
)
我可以使用游戏的 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
的任何信息,也找不到它在 运行 时丢失的原因。
play-slick 2.0.2 使用 slick 3.1.0 所以你必须在 slick-extensions 中匹配这个版本:
libraryDependencies ++= Seq(
...
"com.typesafe.play" % "play-slick_2.11" % "2.0.2",
"com.typesafe.slick" %% "slick-extensions" % "3.1.0",
...
)