Play Framework 2.2.x multiple route files

一笑奈何 提交于 2019-12-06 07:30:48

问题


I've read through the Play! For Scala book's section on modules and I can't seem to figure out how to import the routes from a referenced module. I've set up my module as a library dependency in my build.sbt file and I've tried to import the route in my routes file like so

build.sbt:

libraryDependencies ++= Seq(
  "org.webjars" %% "webjars-play" % "2.2.0", 
  "default" % "mymodule" % "1.0-SNAPSHOT"

routes

...
-> /api/mymodule mymodule.routes

mymodule contains a routing file called mymodule.routes. I don't really see how this could work however I don't fully understand what's going on so I'm not sure what else to try.

I've also tried abandoning the routes file in my referenced module and sticking a new routing file in my conf directory called mymodule.routes and that doesn't work either. Any help would be appreciated. Thanks!


回答1:


I believe to take advantage of routing from a module, you have to structure your project as a multi-project build, not a library dependency.

Take a look at http://www.playframework.com/documentation/2.2.x/SBTSubProjects for how to setup the multi-project build.




回答2:


Have you tried including the routes file from your referenced module in the default routes file? If not try:

include "api/mymodule/routes"


来源:https://stackoverflow.com/questions/20615280/play-framework-2-2-x-multiple-route-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!