Play Framework Slick 3.0.3 Mysql
Play Framework Slick 3.0.3 Mysql
我正在尝试为我的 Play Framework 2
项目配置 Slick 3.0.3
。
这是我的配置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
在 google 中搜索没有结果。
这是完整的堆栈跟踪
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.apply(Config.scala:64)
at play.api.db.slick.Config$$anonfun.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$$anonfun$apply.apply(SlickDDLPlugin.scala:32)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart$$anonfun$apply.apply(SlickDDLPlugin.scala:24)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart.apply(SlickDDLPlugin.scala:24)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart.apply(SlickDDLPlugin.scala:23)
at play.api.db.slick.plugin.SlickDDLPlugin.onStart(SlickDDLPlugin.scala:23)
at play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91)
at play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91)
at play.api.Play$$anonfun$start.apply$mcV$sp(Play.scala:91)
at play.api.Play$$anonfun$start.apply(Play.scala:91)
at play.api.Play$$anonfun$start.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$$anonfun$apply$$anon.<init>(ApplicationSpec.scala:41)
at ApplicationSpec$$anonfun$$anonfun$apply.apply(ApplicationSpec.scala:41)
at ApplicationSpec$$anonfun$$anonfun$apply.apply(ApplicationSpec.scala:41)
原来是进化插件的问题。添加 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,slick 3.0 只能从 2.4 开始运行
plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")
我正在尝试为我的 Play Framework 2
项目配置 Slick 3.0.3
。
这是我的配置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
在 google 中搜索没有结果。
这是完整的堆栈跟踪
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.apply(Config.scala:64)
at play.api.db.slick.Config$$anonfun.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$$anonfun$apply.apply(SlickDDLPlugin.scala:32)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart$$anonfun$apply.apply(SlickDDLPlugin.scala:24)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart.apply(SlickDDLPlugin.scala:24)
at play.api.db.slick.plugin.SlickDDLPlugin$$anonfun$onStart.apply(SlickDDLPlugin.scala:23)
at play.api.db.slick.plugin.SlickDDLPlugin.onStart(SlickDDLPlugin.scala:23)
at play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91)
at play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91)
at play.api.Play$$anonfun$start.apply$mcV$sp(Play.scala:91)
at play.api.Play$$anonfun$start.apply(Play.scala:91)
at play.api.Play$$anonfun$start.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$$anonfun$apply$$anon.<init>(ApplicationSpec.scala:41)
at ApplicationSpec$$anonfun$$anonfun$apply.apply(ApplicationSpec.scala:41)
at ApplicationSpec$$anonfun$$anonfun$apply.apply(ApplicationSpec.scala:41)
原来是进化插件的问题。添加 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,slick 3.0 只能从 2.4 开始运行
plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")