问题描述
我已经阅读了Play!对于Scala书中有关模块的部分,我似乎无法弄清楚如何从引用的模块中导入路由.我已经在build.sbt文件中将模块设置为库依赖项,并且尝试将路由导入到路由文件中,就像这样
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:
build.sbt:
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "2.2.0",
"default" % "mymodule" % "1.0-SNAPSHOT"
路线
...
-> /api/mymodule mymodule.routes
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.
我也尝试过放弃引用模块中的路由文件,并将新的路由文件粘贴到名为mymodule.routes的conf目录中,但这也不起作用.任何帮助,将不胜感激.谢谢!
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!
推荐答案
我相信要利用模块路由的优势,您必须将项目结构化为多项目构建,而不是库依赖关系.
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.
看看 http://www.playframework.com/documentation/2.2. x/SBTSubProjects 了解如何设置多项目构建.
Take a look at http://www.playframework.com/documentation/2.2.x/SBTSubProjects for how to setup the multi-project build.
这篇关于播放Framework 2.2.x多个路由文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!