1
votes

I am trying to set up Ebean for a Play 2.4.4 project.

However, I seem not to be able to import Ebean and JPA using

import com.avaje.ebean.*;
import javax.persistence.*;

or just for the Model class

import com.avaje.ebean.Model;

since I always get a "cannot resolve import" leading to obvious compilation errors when I let my model extend the class Model or when I use annotations.

I followed the instructions from https://www.playframework.com/documentation/2.4.4/JavaEbean by adding

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

to my project/plugins.sbt

and

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

to build.sbt in the projects root directory. I suppose "myProject" has to be replaced with the actual name of the project in the lines above (?). Also there already is a line

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

in the build.sbt and I tried just adding PlayEbean here as well as to delete it, when using the above code.

In the application.conf I added

ebean.default = ["models.*"]

However, I believe that should only allow ebean to find my own models.

I am not really a "programming expert" and have tried everything I can think of as well as reading everything I could find regarding Play and Ebean...however, when I read https://www.playframework.com/documentation/2.4.4/Migration24, I figure, that my problem has something to do with Ebean having been pulled into an external project.

I would be very happy about any support I can get.

1

1 Answers

1
votes

Ok, problem resolved, here's the solution:

After editing the project/plugins.sbt and build.sbt you need to generate the eclipse project files (again) by entering

activator eclipse 

or

activator eclipse with-source=true

in the console within your project folder. After creating the eclipse project files, eclipse can resolve the imports. I would expect that you have to do the same if you use IntelliJ.

"myProject" in the lines you add to your build.sbt actually does not have to be replaced with the actual name of your project, as I suspected earlier, just leave "myProject".

I hope this helps you if you're encountering the same problem.