我正在尝试为Slick 3.0.3
项目配置Play Framework 2
。
这是我的配置application.conf
db.default.url="jdbc:mysql://localhost/entquiz?characterEncoding=UTF-8"
db.default.driver="com.mysql.jdbc.Driver"
db.default.user=entquiz
db.default.pass="qFbR3CW6"
db.default.host="localhost"
在我的代码中,我正在尝试与
连接val db = Database.forDataSource(DB.getDataSource())
我使用的内容无关紧要(forDataSource
或forConfig
)我得到同样的错误
Slick error : jdbc driver not defined in application.conf
for db.driver.MySQL.defaultStringType.driver key
在谷歌搜索没有结果。
这是完整堆栈跟踪
Configuration error[Slick error : jdbc driver not defined in application.conf for db.driver.MySQL.defaultStringType.driver key]
Configuration error: Configuration error[Slick error : jdbc driver not defined in application.conf for db.driver.MySQL.defaultStringType.driver key]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
at play.api.Configuration.reportError(Configuration.scala:743)
at play.api.db.slick.Config$$anonfun$1.apply(Config.scala:64)
at play.api.db.slick.Config$$anonfun$1.apply(Config.scala:64)
at play.api.db.slick.Config$class.driver(Config.scala:63)
at play.api.db.slick.Config$.driver(Config.scala:77)
at play.api.db.slick.plugin.SlickDDLPlugin.evolutionScript(SlickDDLPlugin.scala:49)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart$1$$anonfun$apply$1.apply(SlickDDLPlugin.scala:32)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart$1$$anonfun$apply$1.apply(SlickDDLPlugin.scala:24)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart$1.apply(SlickDDLPlugin.scala:24)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart$1.apply(SlickDDLPlugin.scala:23)
at play.api.db.slick.plugin.SlickDDLPlugin.onStart(SlickDDLPlugin.scala:23)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.Play$.start(Play.scala:90)
at play.api.test.PlayRunners$class.running(Helpers.scala:48)
at play.api.test.Helpers$.running(Helpers.scala:403)
at play.api.test.WithApplication.around(Specs.scala:23)
at play.api.test.WithApplication.delayedInit(Specs.scala:20)
at ApplicationSpec$$anonfun$1$$anonfun$apply$1$$anon$1.<init>(ApplicationSpec.scala:41)
at ApplicationSpec$$anonfun$1$$anonfun$apply$1.apply(ApplicationSpec.scala:41)
at ApplicationSpec$$anonfun$1$$anonfun$apply$1.apply(ApplicationSpec.scala:41)
答案 0 :(得分:2)
事实证明,问题在于evolutions插件。在添加了play-slick-evolution依赖之后,问题就消失了。
build.sbt
"com.typesafe.play" %% "play-slick" % "1.1.0"
"com.typesafe.play" %% "play-slick-evolutions" % "1.1.0"
我的游戏框架也是2.3.8,光滑3.0仅适用于2.4
plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")