PlayFramework how to access routes in view from other submodule view

試著忘記壹切 提交于 2019-12-23 02:40:33

问题


I am writting application in Play Framework using submodules:

  • common
  • shopping
  • ctd

I would like to have in my view link to view from other module. /modules/common/app/views/choose.scala.html:

@main() {
   <a href="@controllers.common.routes.Index.index">common module</a>
   <a href="@controllers.shopping.routes.Index.index">shopping module</a>
}

That code gives me an error:

Compilation error
object shopping is not a member of package controllers
        <a href="@controllers.shopping.routes.Index.index">

Please help me. How can I make this code compile correctly?

My main routes file:

# Include sub projects
->  /               common.Routes
->  /cirs           ctd.Routes
->  /shopping       shopping.Routes

My shopping.routes file:

GET    /                                   controllers.shopping.Index.index()

Problem lies with that the play framework dosnt see my controllers route that are in other package than the view that I call from an other module views. How can I fix it?

My eclipse ide sees my other modules, so I can choose them, but it dosnt compile:

And compilation output:

    [info] Compiling 1 Scala source to /home/korbeldaniel/Aplikacje/Eclipse/SVP/modules/common/target/scala-2.10/classes...
[error] /home/korbeldaniel/Aplikacje/Eclipse/SVP/modules/common/app/views/AppChooser.scala.html:26: object shopping is not a member of package controllers
[error]                         <a href="@controllers.shopping.routes.Index.index()">
[error]                                               ^
[error] one error found
[error] (common/compile:compile) Compilation failed
[error] application - 

! @6jhoo2i44 - Internal server error, for (GET) [/aplikacje] ->

play.PlayExceptions$CompilationException: Compilation error[object shopping is not a member of package controllers]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
        at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:304) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:298) ~[na:na]
        at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]

my main build.sbt file:

import play.Project._
import sbt._
import Keys._
name := "svp"

playJavaSettings

version := "2.0.0_(20140725)"

libraryDependencies ++= Seq(
  javaJdbc, 
  javaJpa, 
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "mysql" % "mysql-connector-java" % "5.1.27",
  "org.mindrot" % "jbcrypt" % "0.3m",
  cache
  )

  lazy val common = project.in(file("modules/common"))
  lazy val cirs = project.in(file("modules/cirs"))
  lazy val shopping = project.in(file("modules/shopping"))
  lazy val admin = project.in(file("modules/admin"))


val main = project.in(file("."))
  .dependsOn(common).aggregate(common)
  .dependsOn(cirs).aggregate(cirs)
  .dependsOn(shopping).aggregate(shopping)
  .dependsOn(admin).aggregate(admin)

来源:https://stackoverflow.com/questions/25912001/playframework-how-to-access-routes-in-view-from-other-submodule-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!