简体   繁体   中英

How to add jdbc dependency to Play project?

I'm using play 2.2.2 .

I'd like to enable jdbc library in a Play/Scala project as mentioned in Accessing an SQL database .

Here's my 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"
)

While compiling the project, I get following jdbc not found error,

$ /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

My rootproject/build.sbt simply is

  import play.Project._                                                                                                                               

  name := "smartad-backend"                                                                              

  version := "1.0"                                                                                       

  playScalaSettings  

References

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

You should combine both of those blocks into your build.sbt file. plugins.sbt is for adding sbt plugins, such as the play sbt plugin. But that's about it.

import play.Project._                                                                                                                               

name := "smartad-backend"                                                                              

version := "1.0"                                                                                       

playScalaSettings 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM