从 Play 应用程序连接到 Apache Derby 的问题

Issues in connecting to Apache Derby From Play Application

我无法尝试通过我的 Play (2.3.9) 应用程序连接到嵌入式 Apache Derby 数据库。在application.conf中有如下配置:

DATABASE_URL_DB = "derby:MyDB"
db.default.driver = org.apache.derby.jdbc.EmbeddedDriver
db.default.url="jdbc:"${DATABASE_URL_DB}

(我在 Derby 安装目录中有 MyDB DB 目录——这是默认的)。

以下是我尝试执行的控制器代码(文件的片段):

package controllers
import play.api.db._
import play.api.mvc._
import play.api.Play.current

object Application extends Controller {

 def test = Action {

    var outString = "Number is "
    val conn = DB.getConnection()
    try {
      val stmt = conn.createStatement
      val rs = stmt.executeQuery("SELECT 9 as testkey ")
      while (rs.next()) {
        outString += rs.getString("testkey")
      }
    } finally {
      conn.close()
    }
    Ok(outString)
  }
}

现有的依赖项(与其他项一起):

libraryDependencies ++= Seq( jdbc , cache , ws)
libraryDependencies += "org.apache.derby" % "derby" % "10.12.1.1"

在路线中(与其他路线一起):

GET     /globalTest                 controllers.Application.test

我收到错误:NoClassDefFoundError: Could not initialize class org.apache.derby.jdbc.EmbeddedDriver

有人能指出问题吗?提前致谢。

问题已通过最大限度地减少 build.sbt 中的依赖项数量得到解决。当然,我的项目中的依赖项之一似乎正在干扰 Derby 驱动程序。