Play Framework: split routes in multiple files without sub projects

后端 未结 2 534
北海茫月
北海茫月 2020-12-08 20:13

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

相关标签:
2条回答
  • 2020-12-08 20:36

    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()
    
    0 讨论(0)
  • 2020-12-08 20:46

    If your file name is technical.routes, while including the file, mention technical.Routes (caps).

    The parameter after -> is the url prefix, so to access any url of technical.routes file, you need to add the prefix.

    http://127.0.01/technical/{defined url in technical.routes file}

    0 讨论(0)
提交回复
热议问题