playframework - package javax.persistence does not exist

穿精又带淫゛_ 提交于 2019-12-01 21:39:00

Have you updated your project dependencies in Build.scala? Not sure if anything has changed in Play 2.2.1 but for Play 2.1.3 dependencies in Build.scala would look like this:

  val appDependencies = Seq(
    javaCore,
    javaJdbc,
    javaEbean
  )

EDIT: Once you update your dependencies in Build.scala don't forget to update dependencies in your IDEA or Eclipse by running corresponding play command, e.g.

play idea

Playframework is generating the IDEA specific files when you run "play idea" (if you're using Eclipse, run "play eclipse"). If you imported the project in the same way the tutorial explained, you should have the necessary JARs already available in the project.

If it's still not working, verify if IDEA correctly assigned a JDK to your project.

Try to understand what this framework is doing under the hood, don't just try to make it work and ignore the important stuff.

I had the same problem and I was using Eclipse. I included @Entity, e.g. and in my project console I typed eclipse with-source=true. After a "Refresh" in my Eclipse project and a "Clean", it brings me all JARs and then I clicked on the issue and the IDE offered the possibility to include javax.persistence.*, play.db.ebean.Model, etc.

I was having the same problem, while using a heavily modified version of Eclipse Neon.
The clue to solving it for me, was that the only place I was seeing the errors was during a Maven build. The Eclipse IDE was able to compile and run the program just fine.
I was able to solve it by adding a couple of dependencies to the project's pom.xml file. See below for the xml code for the dependencies.
I was able to get the groupId's and artifactId's versions by drilling down the directories out on Maven Central. I just walked the tree until I found the metadata.xml files for the persistence.core and the persistence.jpa artifacts.

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.core</artifactId>
        <version>2.6.4</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa</artifactId>
        <version>2.6.4</version>
        <scope>compile</scope>
    </dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!