I am new to Play Framework
and trying to setup a very small project in Intellij
. So, I followed some basic steps:
Java
class file in Controller package. config/routes
file. public class TestController extends Controller {
public F.Promise<Result> createTest() {
return F.Promise.promise(() -> TestEndpoints.createTest(Json.fromJson(request().body().asJson(),
Test.class))).map((result) -> ok(Json.toJson(result)));
}
POST /Test controllers.TestController.createTest()
When I run the project I got this error:
value createTest is not a member of object controllers.TestController
Why is this happening. One thing I just noticed that my Controller folder has Application.scala
not Application.java
. What I am doing wrong here?
Play switched to using dependency injection and therefore the way to reference a function in your Controller is:
POST /Test @controllers.TestController.createTest()
Notice the '@'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.