2

i have an application that connects to two databases, default database models are in the root project and the second database models are in the sub-project. my projects, a brief folder structure looks something like so

[root]/build.sbt
[root]/conf/application.conf
[root]/app/models/Author.java (and other models)
[root]/module/build.sbt 
[root]/module/app/mods/User.java

and the application.conf has ebean configured like so

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/main"
db.default.username=postgres
db.default.password="password"

db.second.driver=org.postgresql.Driver
db.second.url="jdbc:postgresql://localhost:5432/second"
db.second.username=postgres
db.second.password="password"

ebean.default = ["models."]
ebean.second = ["mods."]

and the build.sbt like this:

lazy val module = project.in(file("module")).enablePlugins(PlayJava, PlayEbean, PlayEnhancer)
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
.aggregate(module)
.dependsOn(module)

but when i run the app i get this exception

Error injecting constructor, java.lang.IllegalStateException: Bean class mods.User is not enhanced?

obviously the models in the subproject are not being enhanced. How do i get this to work?

1 Answer 1

3

Try adding the below in the build.sbt of your sub-project:

playEbeanModels in Compile := Seq("mods.*")

This tells the Play Framework to also look at your sub-project when looking for model classes. You can find a longer explanation in the paragraph "Configuring the sbt plugin" in the Play Framework Documentation.

This solution worked for me (after reloading and compiling the project).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.