play框架:[type bookscontroller不是包控制器的成员]

doinxwow  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(294)

我试图编译,但在控制台上出现以下编译错误
<>@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 -

控制器是

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/

我正在使用playframework2.5.10如何调试这个编译错误?
谢谢你的支持!

5sxhfpxr

5sxhfpxr1#

这可能是因为您的控制器是java类而不是scala类。我知道我自己犯了个错误,把它弄混了。
我在想,尤其是当你得到这个: Compiling 4 Scala sources and 1 Java source 也许包裹不正确。也许应该是 /app/controllers 也许你更容易签入ide。

相关问题