Play Framework:在没有子项目的多个文件中拆分路由 [英] Play Framework: split routes in multiple files without sub projects

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

问题描述

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.

I tried 2 methods:

  • 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.

  • 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.

How to do, please?

解决方案

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.

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 contents:

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

->  /technical technical.Routes

GET     /        controllers.Dashboard.index()

conf/technical.routes contents:

# Routes
# ~~~~

GET     /        controllers.technical.App.index()

这篇关于Play Framework:在没有子项目的多个文件中拆分路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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