使用SORM和Spray Framework使用MySQL

时间:2016-01-06 11:39:26

标签: mysql jdbc spray sorm

我正在尝试通过Spray Framework项目中的SORM查询MySQL存储

import sorm._

case class Event(
  title: String,
  description: String,
  datetime: String
)

object Db extends Instance(
  entities = Set( Entity[Event]() ),
  url = "jdbc:mysql://localhost:3306/test"
)

object Main extends App {
  println(Db.query[Event].fetchOne())
}

但是我通过使用sbt

运行此应用程序来收到一些错误
[error] (run-main-0) java.lang.ExceptionInInitializerError
...
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
...
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

我的build.sbt配置

scalaVersion  := "2.11.6"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

libraryDependencies ++= {
  Seq(
    "io.spray"           %%  "spray-can"     % "1.3.3",
    "io.spray"           %%  "spray-routing" % "1.3.3",
    "com.typesafe.akka"  %%  "akka-actor"    % "2.3.9",
    "org.sorm-framework" %   "sorm"          % "0.3.19",
    "io.spray"           %%  "spray-json"    % "1.2.6",
    "org.slf4j"          %   "slf4j-simple"  % "1.7.2"
  )
}

dependencyOverrides += "org.scala-lang" % "scala-compiler" % scalaVersion.value

Revolver.settings

问题出在哪里? 我为jdbc安装了mysql-connector-java。

0 个答案:

没有答案