play2 using main project views/controllers/models in submodule/subproject and inversely

不问归期 提交于 2019-12-11 11:25:54

问题


I have:

  • main project
  • sub project called "shopping"

I would like to use views from main project inside the subproject. My code of sub project controller:

package controllers.shopping;

public class Application extends Controller {

  public static Result index() {
      return ok(views.html.confirmation.render("ok"));
  }
}

And my main build file

lazy val shopping = project.in(file("modules/shopping"))

val main = project.in(file("."))
    .dependsOn(shopping).aggregate(shopping)

My model class in submodule common:

@Entity
public class AppMode {
    public static AppMode getCurrentConfigurationEntry() {
        return JPA.em().find(AppMode.class, 1L);
    }
}

回答1:


Since main depends on shopping adding a dependency the other way around as well would create a circular dependency so sbt wouldn't be able to know which project to build first.

Break the logic you want out into a second subproject that you depend on from both shopping and main and you will be able to access them in both shopping and main.



来源:https://stackoverflow.com/questions/25763647/play2-using-main-project-views-controllers-models-in-submodule-subproject-and-in

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