Play 2.3.7 sbt multiproject compiler issue

社会主义新天地 提交于 2019-12-11 07:17:36

问题


we're using Play framework 2.3.7 and have set up a multiproject with sbt (sbt version 0.13.5), which is consisting of four modules. In the build.sbt file of the project root we define the modules:

lazy val common = (project in file("modules/common")).enablePlugins(PlayJava, SbtWeb)

lazy val store = (project in file("modules/store")).enablePlugins(PlayJava, SbtWeb).dependsOn(common)

lazy val catalog = (project in file("modules/catalog")).enablePlugins(PlayJava, SbtWeb).dependsOn(common)

lazy val backend = (project in file("modules/backend")).enablePlugins(PlayJava, SbtWeb).dependsOn(common)

lazy val root = (project in file(".")).enablePlugins(PlayJava, SbtWeb).aggregate(common, store, catalog, backend).dependsOn(common, store, catalog, backend)

If we're trying to run our application with

activator run

it compiles the app without an error. After the first request on the mainpage, it starts compiling the whole project again... up to four times. This takes a long time, but after that everything works fine.

So what's the reason, the project is compiled that often? Anyone else stumbled upon this problem?

Thanks.


回答1:


Had the same issue in my project after update to play 2.3.7 with ebean persistence-layer.

I noticed that some classes always get recompiled allthough no change was made to them. This only happened to @Entity-classes that used the annotation @com.avaje.ebean.annotation.Transactional.

Unfortunatly using the annotation @play.db.ebean.Transactional instead doesn't work, it won't execute the database commands within a single transaction. Not sure, wether there is either still a bug in it or this does only work for controller-classes but not for @Entity-classes.

However what fixed the issue for me, was using a try/finally block for creating a transaction as described in the ebean-documentation.

Do you happen to use ebean as persistence layer?

Does removing the @transactional-annnotation fix your problem?



来源:https://stackoverflow.com/questions/27986780/play-2-3-7-sbt-multiproject-compiler-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!