Routing 未在子路由文件中编译路由
我正在用Play 2.3.7开发一个应用程序。 我有这个文件: 我还为每个模型提供了model_v1_*文件,以避免路由文件过长。这是其中之一Routing 未在子路由文件中编译路由,routing,playframework-2.3,Routing,Playframework 2.3,我正在用Play 2.3.7开发一个应用程序。 我有这个文件: 我还为每个模型提供了model_v1_*文件,以避免路由文件过长。这是其中之一 GET / controllers.EpisodeController.list() GET /:key controllers.EpisodeController.load(key: String) POST /
GET / controllers.EpisodeController.list()
GET /:key controllers.EpisodeController.load(key: String)
POST / controllers.EpisodeController.create()
DELETE /:key controllers.EpisodeController.delete(key: String)
问题是,当我想测试EpisodeController.list时,我不能,因为EpisodeController不存在
@Test
public void list() {
Result result = callAction(controllers.routes.ref.EpisodeController.list(), new FakeRequest());
// Assertions on result...
}
如果我在target/scala-2.10/src_managed/main/controllers/routes.java中手动检查,则没有EpisodeController的痕迹,而它存在于controllers包中。当我大摇大摆地运行我的应用程序并进行测试时,一切正常
1 activator clean compile
2 activator eclipse
如果无法在调试模式下运行测试:
activator-jvm调试测试并检查问题所在。。。
也许日志会告诉你更多来自cmd和应用程序的信息,正如@Mikesname在对问题的评论中所解释的,问题是我的控制器在controllers包中。
我将它们放在controllers.mypackage中,并将我的文件命名为mypackage.routes,一切正常。调试模式下没有异常显示。请注意,如果我直接在routes中复制model_v1_Spidences.routes的路由,并删除model_v1_Spidences.routes,则效果很好…请尝试将子路由中引用的控制器放入它们自己的独特包中。否则,路由编译器将用主路由覆盖生成的路由。
1 activator clean compile
2 activator eclipse