Hello Every one I am new in Play Frame work and i want to connect mysql to the my application i did all configuration but when i run my application the i get following error :
my Error:
object PlayMagicForJava is not a member of package play.core.j
In /home/trainee02/simmant/playproject/cms/app/views/main.scala.html at line 0.
my Model class:
package models;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.Constraint;
import play.*;
import play.db.ebean.Model;
@Entity
public class Entry extends Model{
@Id
public Long id;
public String name;
public static Model.Finder<Long, Entry> find = new Model.Finder<Long, Entry>(Long.class, Entry.class);
}
my database configuration:
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/cmsdata?characterEncoding=UTF-8"
db.default.user=root
db.default.password=root
Thanx in advance
thanx munguillermin for answer my question
my Build.scala is:
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "collegecms"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
"mysql" % "mysql-connector-java" % "5.1.18"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
)
}
but i am confuse what is error in my Build.scala can you please explain it.
PlayMagicForJava
is part of the play-java
module.
If you have this error, that's probably because you don't have the dependency on the javaCore
module in your Build.scala
file :
val appDependencies = Seq(
jdbc,
javaCore,
javaEbean,
...
)
val appDependencies = Seq(
// Add your project dependencies here,
"mysql" % "mysql-connector-java" % "5.1.18",
jdbc,
javaCore,
javaEbean
)
try this please and do :
play update reload compile
and then run the application
Well Thanx Every one who answer on my question i just following changes in my configuration and my Build.scala and i get what i want .
my application.conf
db.default.driver="com.mysql.jdbc.Driver"
db.default.url="jdbc:mysql://localhost/regis"
db.default.user=root
db.default.password=root
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
# Ebean configuration
# ~~~~~
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
#
ebean.default="models.*"
my Build.scala:
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "studata"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
"mysql" % "mysql-connector-java" % "5.1.18"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
// Add your own project settings here
)
}
in the above configuration i did some changes and my code is working now thank you sir mguillermin for your kind help you answer help me a lot and sir cyril thank you so much for your answer i change all thing and i type that command then my code is been able to work properly.
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.