Adding MySql to playframework 2.2.1

I am trying to connect to mysql database using playback platform. From my own search, I know that I need to add this line somewhere:

"mysql" % "mysql-connector-java" % "5.1.18"

However, each document / similar question says that this line is either included in the Build.scala file or the build.sbt file, and I have none of these files. When I created my application (as a java application), he gave me only build.properties and plugins.sbt , which are inside the project folder.

Does anyone know how to add this line? Do I need to create one of these files?

My build.properties file:

  sbt.version=0.13.0 

and

plugins.sbt

 // Comment to get more information during initialization logLevel := Level.Warn // The Typesafe repository resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // Use the Play sbt plugin for Play projects addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1") 

UPDATE: after adding

addSbtPlugin("mysql" % "mysql-connector-java" % "5.1.18") to my plugins file:

enter image description here

+7
java mysql playframework
source share
3 answers

You must add lines to your sbt file.

 libraryDependencies ++= Seq( jdbc, anorm, cache, "mysql" % "mysql-connector-java" % "5.1.18" ) 

And after that go to application.config , uncommenting

 # db.default.driver=com.mysql.jdbc.Driver db.default.url="jdbc:mysql://127.0.0.1:3306/test" db.default.user="root" db.default.password="" 
+13
source share

Add this line to plugin.sbt

 addSbtPlugin("mysql" % "mysql-connector-java" % "5.1.18") 
+1
source share

You do not have a build file here $YOUR_PROJECT_NAME\project\Build.scala ?

plugins.sbt should contain the following:

 // The Typesafe repository resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // Use the Play sbt plugin for Play projects addSbtPlugin("play" % "sbt-plugin" % "2.2.0") 

and in Build.scala you should have the following:

  val appDependencies = Seq( // Add your project dependencies here, jdbc, anorm, "mysql" % "mysql-connector-java" % "5.1.18" ) 

To be honest with you, you would be better off running the game executable and creating a project, rather than from IDEA.

cmd: $ play new myAppName

then use the sbt plugin for IDEA or if you have IDEA 13 you can import the project using SBT.

https://github.com/mpeltonen/sbt-idea

0
source share

All Articles