【发布时间】:2018-01-06 22:15:12
【问题描述】:
我在 IntelliJ 上创建了一个 Play Framework 2 项目。这是我的路线文件:
# Home page
GET / controllers.Application.index()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
这是我的应用程序类:
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;
public class Application extends Controller {
public Result index() {
return ok(index.render("Your new application is ready."));
}
}
但是当我去 localhost:9000 我得到这个错误:
value index is not a member of object controllers.Application
我做错了什么?如果它有帮助,当我使用 scala 类时它确实可以正常工作。
编辑:
这是我的 build.sbt 文件:
name := "products"
version := "1.0"
lazy val `products` = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq( jdbc , cache , ws , specs2 % Test )
unmanagedResourceDirectories in Test <+= baseDirectory ( _ /"target/web/public/test" )
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
我注意到我只启用了 PlayScala 插件,因此我将其更改为 PlayJava
lazy val `products` = (project in file(".")).enablePlugins(PlayJava)
但我仍然遇到同样的错误。
【问题讨论】:
-
您使用的是哪个 Play Framework 版本?