gpt4 book ai didi

java - Scala 的 Play 框架 : [type BooksController is not a member of package controllers]

转载 作者:行者123 更新时间:2023-12-02 10:30:23 25 4
gpt4 key购买 nike

我尝试编译,但在控制台上出现以下编译错误

<>@7a6b9ggi8 - 内部服务器错误,对于 (GET) [/books] ->

 play.sbt.PlayExceptions$CompilationException: Compilation error[type BooksController is not a member of package controllers]
at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
at scala.Option.map(Option.scala:145)
at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:49)
at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
at scala.Option.map(Option.scala:145)
at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
[info] Compiling 4 Scala sources and 1 Java source to /Users/Play/PROJ_NAME/target/scala-2.11/classes...
[error] /Users/Play/PROJ_NAME/conf/routes:18: type BooksController is not a member of package

controllers
[error] GET /books controllers.BooksController.index()
[error] /Users/Play/PROJ_NAME/conf/routes:18: type BooksController is not a member of package controllers
[error] GET /books controllers.BooksController.index()
[error] /Users/Play/PROJ_NAME/conf/routes:18: type BooksController is not a member of package controllers
[error] GET /books controllers.BooksController.index()
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] application -

BooksController 是

package controllers;

import play.mvc.Controller;
import play.mvc.Result;

import play.*;
import play.data.*;
import play.mvc.*;
import views.html.*;
//
public class BooksController extends Controller{
public Result index(){
return TODO;
}
}

路线是

GET     /                           controllers.HomeController.index
# An example controller showing how to use dependency injection
GET /count controllers.CountController.count
# An example controller showing how to write asynchronous code
GET /message controllers.AsyncController.message
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)

#フォーム処理アクション
#POST /send controllers.HomeController.send()

#book用
GET /books controllers.BooksController.index()
#GET /books/create controllers.BooksController.create()
#GET /books/:id controllers.BooksController.show(id: Integer)
#GET /books/edit/:id controllers.BooksController.edit(id: Integer)
#POST /books/edit controllers.BooksController.update()
#POST /books/create controllers.BooksController.save()
#GET /books/delete/:id controllers.BooksController.destroy(id: Integer)

GET /about/

我正在使用 Play Framework 2.5.10如何调试这个编译错误?

感谢您的支持!

最佳答案

这可能是因为您的 Controller 是 java 类而不是 scala 类。我知道我自己犯了混淆这一点的错误。

我特别想,因为你得到了这个:编译 4 个 Scala 源代码和 1 个 Java 源代码,并且包可能不正确。也许它应该是 /app/controllers 也许更容易让你检查你的IDE。

关于java - Scala 的 Play 框架 : [type BooksController is not a member of package controllers],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53651313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com