【发布时间】:2015-11-29 16:31:38
【问题描述】:
我尝试使用标准路由文件conf/routes 提供可包含在 Play 应用程序中的模块特定路由:
-> /psmod1 com.escalesoft.psmod1.ctrl.Routes
得到编译错误:
类型 Psmod1Assets 不是包的成员 com.escalesoft.psmod1.ctrl
为了做到这一点,我按照Assets and controller classes should be all defined in the controllers.admin package官方文档中的说明执行了两个步骤
1.在自己的包中定义资产和控制器类
将资产类 Psmod1Assets.scala 定义为:
上述用类替换对象定义解决了问题
2。拆分路由文件
将模块特定的路由文件/conf/com.escalesoft.psmod1.ctrl.routes定义为:
# Routes
# Home page
GET / com.escalesoft.psmod1.ctrl.Application.index
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file com.escalesoft.psmod1.ctrl.Psmod1Assets.versioned(path="/public", file: Asset)
如果你喜欢你可以在github上查看或克隆我的小测试项目的代码:
- 在线:https://github.com/refond/psmod1/tree/routing_issue
- 使用 git:
git clone -b routing_issue https://github.com/refond/psmod1.git
项目使用标准controllers.Assets配置为工作。
转到/conf/com.escalesoft.psmod1.ctrl.routes文件(在com.escalesoft.psmod1.ctrl.routes查看),将controllers.Assets行替换为com.escalesoft.psmod1.ctrl.Psmod1Assets行,重现编译错误。
我已经检查了以下资源:
【问题讨论】:
-
Psmod1Assets 定义中的对象而不是类是罪魁祸首!正如stackoverflow.com/questions/32595309/…中akauppi的评论所指出的那样
标签: playframework module routing playframework-2.4