Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

java - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

File -> Project Structure

Select Sources in Right Pane

Add Source folder

target/scala-XXX/classes_managed

target/scala-XXX/src_managed/main


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...