播放2.3子项目路由“非成员”错误

时间:2015-04-08 07:54:00

标签: playframework-2.3

我无法路由我的子项目,但我认为我已按照所有步骤来包含我的子项目

|- mainProject
 |- app
 |- conf
 |- modules
  |- subProject
   |- app
    |- assets
    |- controllers
     |- subProject
      |- Application.scala
      |- Assets.scala
      |- MyCode.java
    |- models
     |- subProject
      |- MyModel.java
    |- views
     |- subProject
      |- myView.scala.html
    |- conf
     |- subProject.routes

subProject.routes

GET     /                           subProject.app.controllers.subProject.MyCode.index()
POST    /add                        subProject.app.controllers.subProject.MyCode.add
POST    /edit/:id                   subProject.app.controllers.subProject.MyCode.edit(id: Long)
GET     /load/:id                   subProject.app.controllers.subProject.MyCode.load(id: Long)
GET     /list                       subProject.app.controllers.subProject.MyCode.list()

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               subProject.app.controllers.subProject.Assets.at(path="/public", file)
GET     /webjars/*file              controllers.WebJarAssets.at(file)
GET     /javascriptRoutes           subProject.app.controllers.subProject.Application.javascriptRoutes()

myview包含以下行:

<script src="@controllers.subProject.routes.Assets.at("javascripts/myJavascript.js")"></script>

我仍然收到错误

[error] /path/git/mainProject/module/subProject/app/views/subProject/myview.scala.html:8: object subProject is not a member of package controllers
[error]     <script src="@controllers.subProject.routes.Assets.at("javascripts/myJavascript.js")"></script>
[error]                               ^
[error] one error found
[error] (subProject/compile:compile) Compilation failed
[error] Total time: 1 s, completed 07-Apr-2015 17:21:56

我认为我的路线文件是错误的,但如果我这样做就像在文档

中那样
GET     /                           controllers.subProject.myCode.index()

我得到了

[error] /path/git/mainProject/modules/subProject/conf/subProject.routes:6: object MyCode is not a member of package controllers.subProject
[error] GET     /                           controllers.subProject.MyCode.index()

搜索similar问题并没有帮助

我做错了什么?

编辑:我刚发现这个问题掩盖了反向路线的另一个问题

[error] /path/git/mainProject/modules/subProject/target/scala-2.10/src_managed/main/controllers/subProject/routes.java:8: error: cannot find symbol
[error] public static final controllers.subProject.ReverseMyCode MyCode = new controllers.subProject.ReverseMyCode();
[error]                                        ^
[error]   symbol:   class ReverseMyCode
[error]   location: package controllers.subProject
[error] /path/git/mainProject/modules/subProjecy/target/scala-2.10/src_managed/main/controllers/subProject/routes.java:11: error: package controllers.subProject.javascript does not exist
[error] public static final controllers.subProject.javascript.ReverseMyCode MyCode = new controllers.subProject.javascript.ReverseMyCode();
[error]                                                   ^
[error] /path/git/mainProject/modules/subProject/target/scala-2.10/src_managed/main/controllers/subProject/routes.java:16: error: package controllers.subProject.ref does not exist
[error] public static final controllers.subProject.ref.ReverseMyCode MyCode = new controllers.subProject.ref.ReverseMyCode();

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。我认为MyCode.java的包是modules.subProject.app.controllers.subProject.MyCode

这是因为你的IDE在包中创建了你的类。 子项目文件包必须以controllers.subProject.

开头

您的subProject.routes文件必须

GET     /                           controllers.subProject.MyCode.index()
POST    /add                        controllers.subProject.MyCode.add
POST    /edit/:id                   controllers.subProject.MyCode.edit(id: Long)
GET     /load/:id                   controllers.subProject.MyCode.load(id: Long)
GET     /list                       controllers.subProject.MyCode.list()

对于反向路线错误,只需清理项目activator clean compile