如何将jdbc依赖项添加到Play项目?

时间:2014-12-19 17:34:47

标签: scala jdbc sbt playframework-2.2

我正在使用play 2.2.2

我想在Accessing an SQL database中提及的Play / Scala项目中启用jdbc库。

这是我的rootproject/project/plugins.sbt

libraryDependencies ++= Seq(
  jdbc
  "com.google.zxing"   %  "core"                 % "2.0",
  "mysql"              %  "mysql-connector-java" % "5.1.27",
  "com.typesafe.slick" %% "slick"                % "2.1.0",
  "org.slf4j"          %  "slf4j-nop"            % "1.6.4"
)

在编译项目时,我得到了jdbc未找到错误

$ /usr/local/play-2.2.2/play compile
/packup/smartad-core/project/plugins.sbt:8: error: not found: value jdbc
      jdbc
          ^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

我的rootproject/build.sbt只是

  import play.Project._                                                                                                                               

  name := "smartad-backend"                                                                              

  version := "1.0"                                                                                       

  playScalaSettings  

参考

https://www.playframework.com/documentation/2.3.x/ScalaAnorm

1 个答案:

答案 0 :(得分:5)

您应该将这两个块合并到build.sbt文件中。 plugins.sbt用于添加sbt插件,例如play sbt插件。但那是关于它的。

import play.Project._                                                                                                                               

name := "smartad-backend"                                                                              

version := "1.0"                                                                                       

playScalaSettings 

libraryDependencies ++= Seq(
   jdbc,
   ...
)