Play Framework 2.3迁移后没有资源

时间:2014-08-08 18:40:16

标签: resources playframework-2.3

我有一个play framework 2.1应用程序。这个程序工作。然后我迁移到2.2,测试它,它工作。现在我正在迁移到2.3,我得到了一个错误:

[debug] application - Unforseen error for favicon.svg at /public
java.lang.RuntimeException: no resource
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1$$anonfun$13.apply(Assets.scala:237) ~[na:na]
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1$$anonfun$13.apply(Assets.scala:237) ~[na:na]
at scala.Option.getOrElse(Option.scala:120) [na:na]
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1.apply(Assets.scala:237) ~[na:na]
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1.apply(Assets.scala:236) ~[na:na]

有一个/ public文件夹,但所有资源都导致上述错误。该应用程序提供404 Not Found等资源。

任何帮助都会很棒。一些清理程序,我可以删除的缓存文件,重新下载依赖项或者我的配置错误。

以下是我有一些配置文件,以便更好地理解: build.sbt:

import com.typesafe.sbt.less.Import.LessKeys import play.PlayJava

name := """blabla-de"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(   filters,   cache,   javaCore,   javaWs, javaJdbc,   javaEbean,   "org.webjars" % "bootstrap" % "3.0.0",   "org.webjars" % "rjs" % "2.1.11-1-trireme" % "test",   "org.webjars" % "squirejs" % "0.1.0" % "test",   "junit" % "junit" % "4.11" % "test" )


testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")

LessKeys.compress in Assets := true

includeFilter in (Assets, LessKeys.less) := "*.less"

excludeFilter in (Assets, LessKeys.less) := "_*.less"

pipelineStages := Seq(rjs, digest, gzip)

CONF /路线:

# Home page
GET     /                           controllers.Index.index()

GET     /about                      controllers.About.index()

## Contact Page
GET     /contact                    controllers.Contact.index()
POST    /contact                    controllers.Contact.newContact()

## Gallery List
GET     /portfolio                  controllers.Portfolio.index()

## Text(HTML) Page
GET     /impressum                  controllers.Impressum.index()
#GET     /legal
GET     /privacy                    controllers.Privacy.index()

# Map static resources from the /public folder to the / URL path
GET    /*file               controllers.Assets.at(path="/public", file)

项目/ build.properties:

sbt.version=0.13.5

项目/ plugins.sbt:

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1")

// web plugins
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.0.0")

先谢谢你。

1 个答案:

答案 0 :(得分:2)

密钥位于迁移指南中:https://www.playframework.com/documentation/2.4.x/Migration23

  

Play 2.3最大的新功能是引入sbt-web。   总之,sbt-web允许使用Html,CSS和JavaScript功能   将Play的核心分解为一系列纯粹的sbt插件。

公共资源不可用必须由sbt-web的不正确配置引起。

我立即看到的是您忘记启用SbtWeb插件。以下是迁移指南的另一个引用:

  

声明addSbtPlugin可能不足以支持现在的插件   利用自动插件功能。

所以你需要修改build.sbt中的以下行:

lazy val root = (project in file(".")).enablePlugins(PlayJava, SbtWeb)