Play中的PlayMagicForJava错误!框架申请?

时间:2013-07-08 14:08:00

标签: java mysql playframework playframework-2.1

你好每一个我是Play Frame工作的新手,我想将mysql连接到我的应用程序我做了所有配置但是当我运行我的应用程序时,我得到以下错误:

我的错误:

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.

我的Model类:

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);
}

我的数据库配置:

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 munguillermin回答我的问题

我的Build.scala是:

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      
  )

}

但是我很困惑我的Build.scala中的错误是什么,请你解释一下。

3 个答案:

答案 0 :(得分:1)

PlayMagicForJavaplay-java模块的一部分。

如果您有此错误,那可能是因为您没有依赖javaCore文件中的Build.scala模块:

val appDependencies = Seq(
  jdbc,
  javaCore,
  javaEbean,
  ...
)

答案 1 :(得分:1)

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

请尝试这样做:

 play update reload compile

然后运行应用程序

答案 2 :(得分:0)

Well Thanx每个回答我问题的人我只是跟随我的配置和Build.scala的变化,我得到了我想要的东西。

我的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.*"

我的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      
    )

}

在上面的配置中我做了一些更改,我的代码现在正在工作谢谢你先生mguillermin为你的帮助你回答了很多帮助我和sir cyril非常感谢你的回答我改变所有的事情我输入那个命令然后我的代码能够正常工作。