在play framework 2.4.x中反向路由

时间:2016-03-21 16:52:13

标签: scala playframework

我正在尝试将一个应用程序的链接放在另一个应用程序的模板中。 所以我在build.sbt中创建了三个val:

lazy val common: Project = (project in file("modules/common"))
    .enablePlugins(PlayJava, PlayEbean, PlayScala)
    .settings(aggregateReverseRoutes := Seq(admin, web))
    .settings(routesGenerator := InjectedRoutesGenerator)

lazy val admin = (project in file("modules/admin"))
    .enablePlugins(PlayJava, PlayEbean, PlayScala)
    .dependsOn(common)

lazy val web = (project in file("modules/web"))
    .enablePlugins(PlayJava, PlayEbean, PlayScala)
    .dependsOn(common)

我分别将admin/confweb/conf中的路由文件重命名为admin.routesweb.routes

如何将网络项目中的链接放入管理项目? 另外,我应该在项目管理员和网站上保持简单的前向路由吗?

1 个答案:

答案 0 :(得分:1)

有一个aggregateReverseRoutes设置可以让你这样做。只需将此设置添加到您的Web项目中即可。

lazy val admin: Project = (project in file("modules/admin"))
  .enablePlugins(PlayJava, PlayEbean, PlayScala)
  .dependsOn(common)

lazy val web: Project = (project in file("modules/web"))
  .enablePlugins(PlayJava, PlayEbean, PlayScala)
  .dependsOn(common)
  .settings(aggregateReverseRoutes := Seq(admin))