Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
636 views
in Technique[技术] by (71.8m points)

playframework - Play Framework: split routes in multiple files without sub projects

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...