2

Im trying to create small CRUD application using play-java template. Im using typesafe activator through cmd I create new project so now i want enable ebean and have to change mysql database. im using activator 1.3.6, for sql im using my phpmyadmin sql 5.6.20 i googled and i did everything like documentary but still i couldn't solve my problem i couldn't add ebean my project and i couldn't connect mysql connector i did changes using this links Ebean Mysql stackoverflow question but no use i wasted 3 days then i used play2-crud template enter link description here in this i can use eban but i dont know how to enable mysql and im using INTELLIJ IDE if anyone expert help me

Community
  • 1
  • 1
Hamelraj
  • 4,213
  • 4
  • 15
  • 39
  • What errors do you have? I also use https://www.playframework.com/documentation/2.4.x/JavaEbean as a roadmap and got it working within few hours. – Andriy Kuba Nov 13 '15 at 13:24
  • i create ne project ok using play-java then i uncommand in plugin.sbt file 'addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")' ok then in build.sbt i chnged (Playjava) to (Playjava, PlayEbean) when i change PlayEbean red color and thr i have add javaebean under libraryDependencies both eban red color – Hamelraj Nov 13 '15 at 13:26

1 Answers1

1

To enable MySQL

in the application.conf file:

# Database configuration using MySQL database engine
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://127.0.0.1/mydataabse"
db.default.username=yourusername
db.default.password="yourpassword"

and you also need to add MySQL connector to the build.sbt libraryDependencies:

libraryDependencies ++= Seq(
    ...
    "mysql" % "mysql-connector-java" % "5.1.18"
)

To enable Ebean

Add Ebean plugin In to the project\plugins.sbt:

addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0") 

Enable this plugin in the build.sbt:

lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)

Configure Ebean in the conf\application.conf to take models from your model package:

ebean.default = ["my.models.*"]
Andriy Kuba
  • 7,595
  • 2
  • 22
  • 42
  • really thanks its running without any error befor i used 5.6.20 i think that is the problem and i want knw how to enable **eban** when i extend model class to **Model** i want import play.db.ebean.Model. i think u got it what im asking – Hamelraj Nov 13 '15 at 14:15
  • but you write als that when you are using different template then you are able to run ebean but "i dont know how to enable mysql" – Andriy Kuba Nov 13 '15 at 14:25
  • do not forget to recompile project after the changes. – Andriy Kuba Nov 13 '15 at 16:00
  • the way i changed three places after i compile through CMD im getting this error 'Play ebean module has been replaced with an external Play ebean plugin. See https://playframework.com/documentation/2.4.x/Migration24 for details.' – Hamelraj Nov 13 '15 at 16:04
  • You need to "remove javaEbean from your libraryDependencies in build.sbt". I saw you add this "have add javaebean under libraryDependencies " - remove it – Andriy Kuba Nov 13 '15 at 16:08
  • name := """play-java-app""" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) scalaVersion := "2.11.6" libraryDependencies ++= Seq(javaJdbc,javaEbean,cache, javaWs, "mysql" % "mysql-connector-java" % "5.1.18") // Play provides two styles of routers, one expects its actions to be injected, the // other, legacy style, accesses its actions statically. routesGenerator := InjectedRoutesGenerator fork in run := true` here PlayBean red color and Javaeban diffrent color apart Javajdbc – Hamelraj Nov 13 '15 at 16:08
  • please, remove "javaEbean" form the libraryDependencies: "javaJdbc,javaEbean,cache," => "javaJdbc,cache," – Andriy Kuba Nov 13 '15 at 16:09
  • yes i removed still PlayEbean is red color and when i try to extend model class to Model i cant find play.db.ebean.Model package – Hamelraj Nov 13 '15 at 16:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95055/discussion-between-hamel-raj-and-andriy-kuba). – Hamelraj Nov 13 '15 at 16:16
  • Take a look int the chat again – biesior Nov 13 '15 at 16:55
  • Thankyou alot two both of u :) – Hamelraj Nov 13 '15 at 17:46