Play框架:将路线拆分为多个文件,而无需子项目 [英] Play Framework: split routes in multiple files without sub projects

查看:99
本文介绍了Play框架:将路线拆分为多个文件,而无需子项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的游戏项目很大,路由文件约为1Mb.现在,当scala编译时,由于从路由文件创建的路由和反向路由scala文件(也很大),我会遇到方法代码太大"的异常.

My play project is massive and the routes file is approx 1Mb. Now, when scala compiles, I have the exception "Method code too large" because of the routing and the reverse routing scala files created from my routes file(that are big too).

因此,我需要在没有子项目的情况下拆分路由文件.确实,我不能将我的项目分成子项目,因为它的组件是相互依赖的.

So, I need to split my routes file without subprojects. Indeed, I can't split my project into subprojects because its components are interdependent.

我尝试了2种方法:

  • 我添加了一个名为technical.routes的新conf文件,在其中添加了一些路由,从"routes"中删除了相同的路由,并使用-> technical.Routes"导入了该文件 一切都可以编译,我没有以前的异常,但是出了点问题,因为当它停止编译时,它会一遍又一遍...永远不会结束.

  • I added a new conf file called technical.routes, add some routes inside, remove the same routes from "routes", and import the file with "-> technical.Routes" Everything compiles, I don't have my previous exception, but something is wrong because when it stops compiling, it starts over and over... and never ends.

我添加了一个名为Technical.routes的新conf文件,在其中添加了一些路由,从"routes"中删除了相同的路由,但是我没有将其导入到我的主路由文件中,而是将其添加到conf文件中: "application.router ="路线,技术路线.". 但这是行不通的,因为在这里只能声明一条路由.

I added a new conf file called technical.routes, add some routes inside, remove the same routes from "routes", but instead of importing it in my main routes file, I added it in the conf file: "application.router="routes, technical.routes"". But it's not working because only one route must be declared here.

请问该怎么办?

推荐答案

好,第一种方法有效.我从头开始,它奏效了.在编译命令之前,我做了一个干净的命令.看来旧的编译文件是造成我问题的原因.

Well, the first method is working. I started from scratch and it worked. I did a clean command before the compile command. It seems that old compiled files were the cause of my problem.

请注意,路由文件中的程序包名称不能重叠.例如.在此示例中,technical.routes文件包含controllers.technical中的所有路由,而主路由文件中不能包含controllers.technical包中的任何路由.

Be careful to note that you cannot have an overlap in package names in the routes files. E.g. in this example, the technical.routes file contains all routes in the controllers.technical and the main routes file cannot contain any routes in the controllers.technical package.

conf/routes内容:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

->  /technical technical.Routes

GET     /        controllers.Dashboard.index()

conf/technical.routes内容:

# Routes
# ~~~~

GET     /        controllers.technical.App.index()

这篇关于Play框架:将路线拆分为多个文件,而无需子项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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