I'm following one of the play framework tutorials, but I'm getting compile errors whenever I try to use reverse routing. Firstly,
public static Result javascriptRoutes() {
response().setContentType("text/javascript");
return ok(
Routes.javascriptRouter("jsRoutes",
controllers.routes.javascript.Projects.add(),
controllers.routes.javascript.Projects.delete(),
controllers.routes.javascript.Projects.rename(),
controllers.routes.javascript.Projects.addGroup()
)
);
}
where the error shown in intelliJ is 'cannot resolve method javascriptRouter(java.lang.String, ?, ?, ?, ?)'
But also in the a unit test:
@Test
public void notAuthenticated() {
Result result = callAction(
controllers.routes.ref.Application.index(),
fakeRequest()
);
assertEquals(303, status(result));
assertEquals("/login", header("Location", result));
}
where it cannot resolve the index method.
Is this a problem with intelliJ, or am I missing something within play?
For the first part, here is the entry in my routes file:
GET /assets/javascripts/routes controllers.Application.javascriptRoutes()
and my controller, Projects, has got the defined methods.
File -> Project Structure
Select Sources in Right Pane
Add Source folder
target/scala-XXX/classes_managed
target/scala-XXX/src_managed/main
I was running into the same problem and found the solution here: https://github.com/playframework/Play20/issues/969
In short:
javascript
and ref
under the controllers packageactivator compile
and now Intellij should get it // used to be 'play compile'
activator idea
again // used to be 'play compile'*If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With