java - Play Framework 2.4.x - Subprojects with database -
heys guys,
i hope can me subprojects in play framework 2.4.x. i'm developing play project (i call root) subproject. both have ebean models , want save these models in different databases. tried many possibilies i'm not able work out.
- defining database , ebean configuration in [root]/conf/application.conf , other 1 in [root]/modules/sub/conf/application.conf (with different database names). error "creationexception: unable create injector, see following errors: 1) error injecting constructor, java.lang.illegalstateexception: bean class models.rootmodel not enhanced?"
- defining 1 database , ebean configuration in root's configuration , 1 in subproject's configuration same database name. error "persistenceexception: subproject.models.submodel not entity bean registered server?"
- defining both databases , ebean configuration in root project , define database subproject in configuration, same error in 1.
- no configuration in subproject, error: "creationexception: unable create injector, see following errors: 1) error injecting constructor, java.lang.illegalstateexception: bean class subproject.models.submodel not enhanced?"
how setup databases play framework project , subproject?
my files in these folders:
[root]/build.sbt [root]/conf/application.conf [root]/app/models/rootmodel.java [root]/modules/sub/conf/application.conf [root]/modules/sub/conf/app/models/subproject/models/submodel.java
my [root]/build.sbt:
import com.typesafe.play.sbt.enhancer.playenhancer name := """rootproject""" version := "1.0" lazy val root = (project in file(".")) .enableplugins(playjava, playebean, playenhancer) .aggregate(sub) .dependson(sub) .settings( twirlkeys.templateimports += "subproject.models._" ) lazy val sub = project.in(file("modules/sub")) .enableplugins(playjava, playebean, playenhancer) scalaversion := "2.11.6"
defining of database , ebean configuration in application.conf:
db.default.driver=org.h2.driver db.default.url="jdbc:h2:./db/default;db_close_delay=-1" db.default.username="sa" db.default.password="..." db.sub.driver=org.h2.driver db.sub.url="jdbc:h2:./db/sub;db_close_delay=-1" db.sub.username="sa" db.sub.password="..." ebean.default=["models.*"] ebean.sub=["subproject.models.*"]
okay, figured out myself. it's quite simple, @ play framework documentation.
if you're having problems 'persistenceexception: sub.model.submodel not entity bean registered server?', @ multiple databases play framework 2.1.x.
Comments
Post a Comment