Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve reverse routing methods in IntelliJ

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.

like image 632
Conor Pender Avatar asked May 21 '13 17:05

Conor Pender


2 Answers

File -> Project Structure

Select Sources in Right Pane

Add Source folder

target/scala-XXX/classes_managed

target/scala-XXX/src_managed/main

like image 94
darren rose Avatar answered Sep 28 '22 10:09

darren rose


I was running into the same problem and found the solution here: https://github.com/playframework/Play20/issues/969

In short:

  • Create the directories javascript and ref under the controllers package
  • Run activator compile and now Intellij should get it // used to be 'play compile'
  • If you still got the errors try to run activator idea again // used to be 'play compile'*
like image 34
Markus Knittig Avatar answered Sep 28 '22 11:09

Markus Knittig