【发布时间】:2015-08-14 06:31:22
【问题描述】:
我正在使用 Play 2.4.0,我一直在尝试按照主页上的教程进行操作:https://playframework.com/ 这是针对 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>
}
还有我的routes 文件:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
POST /person controllers.Application.addPerson()
GET /persons controllers.Application.getPersons()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
我有同样的例子在 Play 2.3.9 上运行良好
在 2.4.0 的文档中,我看不出使用公共资产有什么不同:https://www.playframework.com/documentation/2.4.0/Assets
所以...任何帮助将不胜感激。
【问题讨论】:
-
你尝试运行一次
sbt clean吗? -
我试过
activator clean和activator clean-files但我得到了同样的错误。 -
IIRC,我在迁移到 2.4 时遇到了类似的错误。我的资产路线如下所示:
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)。注意使用versioned而不是at。也许这有帮助。如果没有,发布路线配置可能会有所帮助。 -
忘了提到你还必须在
index.scala.html中将@routes.Assets.at("javascripts/index.js")更改为@routes.Assets.versioned("javascripts/index.js") -
@Roman 请创建答案,以便它可以被接受和投票。
标签: java playframework java-8 playframework-2.4