编程语言
首页 > 编程语言> > playframework-包javax.persistence不存在

playframework-包javax.persistence不存在

作者:互联网

我在使用数据库时遇到问题
我正在学习本教程
http://vimeo.com/58969923#(来自playframework.com页面的一个)
在模型中:

播放2.2.1 / jcirs / app / models / MedicalIncident.java

公共类MedicalIncident扩展了模型{}

我正在尝试使用实体.为此,我必须导入:
javax.persistence.*和play.db.ebean.*
但找不到它们.
错误是

package javax.persistence does not exist

我该怎么办?
使用任何其他数据库引擎?还是应该下载一些依赖项.
我想采用Playframework的最佳方法.
请帮忙.

我的配置
application.conf:

 db.default.driver=org.h2.Driver
 db.default.url="jdbc:h2:mem:play"
 ebean.default="models.*"

堆栈跟踪:

[jcirs] $run 8081

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:8081

(Server started, use Ctrl+D to stop and go back to the console...)

[info] Compiling 5 Scala sources and 5 Java sources to /home/daniel/play-2.2.1/jcirs/target/scala-2.10/classes...
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:4: error: package javax.persistence does not exist
[error] import javax.persistence.*;
[error] ^
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:6: error: package play.db.ebean does not exist
[error] import play.db.ebean.*;
[error] ^
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:14: error: cannot find symbol
[error] public class MedicalIncident extends Model {
[error]                                      ^
[error]   symbol: class Model
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:13: error: cannot find symbol
[error] @Entity
[error]  ^
[error]   symbol: class Entity
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:15: error: cannot find symbol
[error]     @id
[error]      ^
[error]   symbol:   class id
[error]   location: class MedicalIncident
[error] /home/daniel/play-2.2.1/jcirs/app/controllers/MedicalIncident.java:21: error: cannot find symbol
[error]         MedicalIncident medical_incident = Form.form(MedicalIncident.class).bindFormRequest().get();
[error]                                            ^
[error]   symbol:   variable Form
[error]   location: class MedicalIncident
[error] 6 errors
[error] (compile:compile) javac returned nonzero exit code
[error] application - 

! @6gfjpj0cf - Internal server error, for (GET) [/] ->

play.PlayExceptions$CompilationException: Compilation error[error: package javax.persistence does not exist]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
        at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:304) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:298) ~[na:na]
        at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
[warn] play - No application found at invoker init

解决方法:

您是否在Build.scala中更新了项目依赖项?
不知道是否有任何的播放2.2.1但是对于播放2.1.3依赖于Build.scala看起来像这样发生了变化:

  val appDependencies = Seq(
    javaCore,
    javaJdbc,
    javaEbean
  )

编辑:
一旦您在Build.scala中更新了依赖项,就不要忘记通过运行相应的play命令来更新IDEA或Eclipse中的依赖项.

play idea

标签:ebean,persistence,java,playframework-2-2
来源: https://codeday.me/bug/20191122/2059459.html