使用子模块/子项目中的主项目视图/控制器/模型以及相反地使用play2 [英] play2 using main project views/controllers/models in submodule/subproject and inversely

查看:127
本文介绍了使用子模块/子项目中的主项目视图/控制器/模型以及相反地使用play2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

  • 主要项目
  • 名为购物"的子项目

我想使用子项目中主项目的视图. 我的子项目控制器代码:

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"));
  }
}

还有我的主要构建文件

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);
    }
}

推荐答案

由于main依赖于购物,因此添加依赖项也将产生循环依赖关系,因此sbt将无法知道首先构建哪个项目

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.

这篇关于使用子模块/子项目中的主项目视图/控制器/模型以及相反地使用play2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆