我有一个可以在Play 2.4上正常运行的应用程序,因此决定用Play 2.5对其进行升级,但是我的Twirl模板现在出现了一些问题。 编译时,现在找不到路由包,而在迁移之前它可以正常工作:
[error] /Users/myname/Projects/myprpject/app/views/account.scala.html:14: not found: value routes
还有我的account.scala.html文件中的代码示例:
<a href="@routes.Application.logout" class="thumbnail">
如果我用controllers.routes替换路由,则编译工作正常,但如果可以避免的话,我不想更改所有视图。我猜这是由于默认的路由程序包或类似的东西,在2.5版本中有所更改,但无法完全弄清楚原因。
如果有帮助,我在迁移过程中还会遇到其他编译问题,类似于以下问题:
[error] /Users/rbrodier/Projects/rzretail-bo/app/views/account.scala.html:18: could not find implicit value for parameter messages: play.api.i18n.Messages
[error] /Users/rbrodier/Projects/rzretail-bo/app/views/admin/administration/index.scala.html:15: not found: value flash
不确定是否相关,但这是我的Build.scala(如果您习惯使用,则类似于build.sbt文件):
import com.typesafe.sbt.less.Import.LessKeys
import com.typesafe.sbt.web.SbtWeb.autoImport._
import com.typesafe.sbt.web.SbtWeb
import sbt._
import sbt.Keys._
import play.sbt.Play.autoImport._
import PlayKeys._
import com.typesafe.sbt.rjs.SbtRjs.autoImport._
object ApplicationBuild extends Build {
val appName = "myproject"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
javaCore, javaJdbc, javaWs, cache
, "mysql" % "mysql-connector-java" % "5.1.43"
, "net.sf.opencsv" % "opencsv" % "2.3"
, "commons-beanutils" % "commons-beanutils-core" % "1.8.3"
, "org.apache.poi" % "poi" % "3.13"
, "org.apache.poi" % "poi-ooxml" % "3.13"
, "org.apache.poi" % "poi-scratchpad" % "3.13"
, "org.apache.commons" % "commons-math3" % "3.5"
, "commons-io" % "commons-io" % "2.5"
, "ch.qos.logback" % "logback-core" % "1.1.3"
, "ch.qos.logback" % "logback-classic" % "1.1.3"
, "org.apache.xmlgraphics" % "fop" % "2.2"
, "org.apache.xmlgraphics" % "batik-codec" % "1.7"
, "com.jolbox" % "bonecp" % "0.8.0.RELEASE"
, "com.google.inject" % "guice" % "3.0"
, "com.mailjet" % "mailjet-client" % "4.1.1"
, "org.jsoup" % "jsoup" % "1.8.3"
)
val main = Project(appName, file("."))
.enablePlugins(play.sbt.Play, play.ebean.sbt.PlayEbean, SbtWeb)
.settings(
sources in doc in Compile := List()
,scalaVersion := "2.11.8"
, javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
, version := appVersion
, libraryDependencies ++= appDependencies
, includeFilter in (Assets, LessKeys.less) := "*.less"
, excludeFilter in (Assets, LessKeys.less) := "_*.less"
, LessKeys.compress := true
, pipelineStages := Seq(rjs)
)
}
任何帮助表示赞赏!
答案 0 :(得分:1)
所以这应该是评论,但我没有足够的代表。看来您的导入位置混乱了。
引用:
如果您使用的是Build.scala而不是build.sbt,则需要导入routesGenerator设置键:
import play.sbt.routes.RoutesCompiler.autoImport._
希望有帮助。