路由未在子路由文件中编译

时间:2015-02-06 17:24:52

标签: routing playframework-2.3

我正在使用Play 2.3.7开发应用程序。 我有这个routes文件:

GET          /api-docs                             controllers.ApiHelpController.getResources

GET         /assets/*file                          controllers.Assets.at(path="/public", file)
GET         /swagger-ui/*file                      controllers.Assets.at(path="/public/swagger-ui", file)

->          /v1/episodes                           model_v1_episodes.Routes
->          /v1/seasons                            model_v1_seasons.Routes
->          /v1/series                             model_v1_series.Routes

我还为每个模型提供model_v1_*个文件,以避免路由文件过长。这是其中之一

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包中存在run。当我{{1}}我的应用程序并使用Swagger进行测试时,一切正常。

2 个答案:

答案 0 :(得分:0)

1 activator clean compile
2 activator eclipse

如果它不能帮助在调试模式下运行测试:

  • activator -jvm-debug test并检查问题是什么......

也许日志会告诉你更多内容(来自cmd和应用程序)

答案 1 :(得分:0)

正如@Mikesname在对该问题的评论中所解释的那样,问题是我的控制器在controllers包中。 我将它们放入controllers.mypackage并命名为我的文件mypackage.routes,一切正常。