Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Play Framework@routes.Assets.at编译错误_Java_Playframework_Java 8_Playframework 2.4 - Fatal编程技术网

Java Play Framework@routes.Assets.at编译错误

Java Play Framework@routes.Assets.at编译错误,java,playframework,java-8,playframework-2.4,Java,Playframework,Java 8,Playframework 2.4,我正在使用Play 2.4.0,我一直在尝试按照主页上的教程进行操作: 这是针对Play 2.3的,在解决了关于Ebean ORM从版本2.3到版本2.4更改的几个问题后,我遇到了以下错误: Compilation error value at is not a member of controllers.ReverseAssets 我的index.scala.html: @(message: String) @main("Welcome to Play") { <scri

我正在使用Play 2.4.0,我一直在尝试按照主页上的教程进行操作: 这是针对Play 2.3的,在解决了关于Ebean ORM从版本2.3到版本2.4更改的几个问题后,我遇到了以下错误:

Compilation error

value at is not a member of controllers.ReverseAssets
我的
index.scala.html

@(message: String)

@main("Welcome to Play") {

    <script type='text/javascript' src="@routes.Assets.at("javascripts/index.js")"></script>

    <form action="@routes.Application.addPerson()" method="post">
        <input type="text" name="name" />
        <button>Add Person</button>
    </form>

    <ul id="persons">
    </ul>
}
我有一个同样的例子,在播放2.3.9时可以正常工作

在2.4.0的文档中,我看不到任何关于使用公共资产的不同之处:


所以。。。任何帮助都将不胜感激。

好吧,总结一下解决方案:游戏让你以两种不同的方式为你的资产服务。sbt web引入了传统的和新的指纹识别方法。无论哪种情况,请确保在视图文件中使用正确的调用:

指纹资产 这是建议使用的服务资产的方法。指纹资产利用积极的缓存策略。您可以在此处阅读有关此主题的更多信息:

路由配置:

GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)
@routes.Assets.versioned("an_asset")
GET     /assets/*file               controllers.Assets.at(path="/public", file)
@routes.Assets.at("an_asset")
确保
文件
的类型指示为
资产

调用视图:

GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)
@routes.Assets.versioned("an_asset")
GET     /assets/*file               controllers.Assets.at(path="/public", file)
@routes.Assets.at("an_asset")

旧式资产 这基本上是sbt web引入之前使用的方法

路由配置:

GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)
@routes.Assets.versioned("an_asset")
GET     /assets/*file               controllers.Assets.at(path="/public", file)
@routes.Assets.at("an_asset")
调用视图:

GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)
@routes.Assets.versioned("an_asset")
GET     /assets/*file               controllers.Assets.at(path="/public", file)
@routes.Assets.at("an_asset")

你试过运行一次
sbt clean
吗?我试过
activator clean
activator clean files
但是我得到了相同的错误。IIRC,我在迁移到播放2.4时遇到了类似的错误。我的资产路由如下所示:
GET/assets/*file controllers.assets.versioned(path=“/public”,file:Asset)
。请注意,在中使用了
版本控制
,而不是
。也许这有帮助。如果没有,那么发布路由配置可能会有所帮助。忘了提到您还必须将
@routes.Assets.at(“javascripts/index.js”)
更改为
@routes.Assets.versionied(“javascripts/index.js”)
请在
index.scala.html
@Roman中创建答案,因此它可以被接受并被升级。IntelliJ错误地报告Assets.versioned()已弃用,尚未修复,请参阅