Java Play Framework 2.4.x-带数据库的子项目
嘿,伙计们 我希望您能在PlayFramework2.4.x中的子项目方面真正帮助我。我正在开发一个带有子项目的Play项目(我称之为root)。两者都有ebean模型,我想将这些模型保存在不同的数据库中。我尝试了很多可能性,但都没能解决Java Play Framework 2.4.x-带数据库的子项目,java,playframework,subproject,Java,Playframework,Subproject,嘿,伙计们 我希望您能在PlayFramework2.4.x中的子项目方面真正帮助我。我正在开发一个带有子项目的Play项目(我称之为root)。两者都有ebean模型,我想将这些模型保存在不同的数据库中。我尝试了很多可能性,但都没能解决 在[root]/conf/application.conf中定义数据库和Ebean配置,在[root]/modules/sub/conf/application.conf中定义另一个配置(使用不同的数据库名称)。然后我得到一个错误“CreationExcept
[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
我的[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"
在application.conf中定义数据库和ebean配置:
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.*"]
好吧,我自己想出来的。这很简单,看看这个
如果您遇到诸如“PersistenceException:sub.model.SubModel不是在此服务器上注册的实体Bean”之类的问题,请查看。好的,我自己解决了。这很简单,看看这个 如果您遇到诸如“PersistenceException:sub.model.SubModel不是在此服务器上注册的实体Bean”之类的问题,请查看