Javaplay将路由文件放在子目录中

发布于 2025-02-05 19:06:46 字数 555 浏览 6 评论 0原文

是否可以从Java Play的路由在单独的目录中吗? 2.8.x)

(假设播放

->      /admin                       FIXME


conf/conf/routes-dir/admin.Routes


据我所知,唯一的选项是将admin.Routes移动到conf/conf/目录。然后,路由文件看起来像这样

->      /admin                       admin.Routes

,但是,我想将所有路由文件保留在单独的目录中

Is it possible to make reference from Java Play's routes file to another route file that is in a separate directory?

(assuming Play 2.8.x)

For example, consider the content of conf/routes

->      /admin                       FIXME

I need the FIXME placholder to reference the admin.routes file inside conf/routes-dir/admin.routes


As far as I know, the only option is to move admin.routes to conf/ directory. Then, routes file would look like this

->      /admin                       admin.Routes

However, I want to keep all routes files inside separate directory

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩饰不了的爱 2025-02-12 19:06:46

中的自定义目录

您可以将自定义目录添加到conform build.sbt

Compile / unmanagedResourceDirectories += "./customDir/"

,或者

Compile / unmanagedResourceDirectories += baseDirectory.value / "customDir"

如果需要从内conf文件夹中添加路由,则必须用于

Compile / unmanagedResourceDirectories += baseDirectory.value / "conf" / "routes_v2"

检查结果,您可以将其用于打印结果来控制

Compile / routes := {
  val value = (Compile / routes).value
  System.out.print("Compile / routes: " + value)
  value
}
Compile / unmanagedResourceDirectories := {
  val value = (Compile / unmanagedResourceDirectories).value
  System.out.print("Compile / unmanagedResourceDirectories: " + value)
  value
}

in sbt

文档

中 - 对此的模块,因为您将在ReverCroutes生成中遇到问题(仅从一个路由文件中生成)
更多有关散布路线文件的信息

You can add your custom directory with routs files to config

build.sbt

Compile / unmanagedResourceDirectories += "./customDir/"

or

Compile / unmanagedResourceDirectories += baseDirectory.value / "customDir"

If you need add routes from inner conf folder, you must use

Compile / unmanagedResourceDirectories += baseDirectory.value / "conf" / "routes_v2"

for checking results you can use this for print results to console

Compile / routes := {
  val value = (Compile / routes).value
  System.out.print("Compile / routes: " + value)
  value
}
Compile / unmanagedResourceDirectories := {
  val value = (Compile / unmanagedResourceDirectories).value
  System.out.print("Compile / unmanagedResourceDirectories: " + value)
  value
}

in Sbt documentation

Update ATTENTION

Please use multi-module for this, because you will take a problem with RevercRoutes generation (will be generated only from one routes file)
MORE information about splitting route file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文