2015-12-08 33 views
1

我有一個連接到兩個數據庫的應用程序,默認數據庫模型在根項目中,第二個數據庫模型在子項目中。 我的項目,一個簡短的文件夾結構看起來像這樣子項目中的Ebean增強播放2.4

[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 

和application.conf已ebean配置,像這樣

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."] 

和build.sbt這樣的:

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

但當我運行應用程序,我得到這個異常

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

顯然,該子項目中的模型未被增強。我如何得到這個工作?

回答

2

嘗試添加下面的子項目的build.sbt

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

這告訴播放框架也看看你的子項目尋找模型類時。您可以在Play Framework Documentation「配置sbt插件」中找到更長的解釋。

此解決方案爲我工作(重新加載和編譯項目後)。