Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse unresolved symbol with Play Framework

I'm a beginner user of Play Framework 2.1.3 and I have just created a new Java application and I have run play eclipse to generate the eclipse project for it. I have also tested so that it works by doing a play run.

So I'm following this tutorial and there is a step where you should add this piece of code:

public static Result index() {
  return redirect(routes.Application.tasks());
}

But I'm getting the message "routes cannot be resolved". I have also tried play compile and in Eclipse doing a clean to no avail.

like image 220
Peter Warbo Avatar asked Sep 02 '13 14:09

Peter Warbo


2 Answers

I was having the same trouble after the recent 2.4.X release of Play and the solution of cleaning/compiling/reimporting wasn't working. The solution for me was to:

  1. Add the below keys to build.sbt
  2. Kill eclipse
  3. ./activator clean
  4. ./activator compile
  5. ./activator eclipse
  6. Re-import into eclipse

The problem is basically that the managed source directory wasn't being created, these lines fix the problem.

 EclipseKeys.projectFlavor := EclipseProjectFlavor.Java           // Java project. Don't expect Scala IDE
 EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  // Use .class files instead of generated .scala files for views and routes 
 EclipseKeys.preTasks := Seq(compile in Compile)                  // Compile the project before generating Eclipse files, so that .class files for views and routes are present
like image 175
Jason Swenski Avatar answered Oct 07 '22 13:10

Jason Swenski


  1. run play clean-all from your project directory
  2. run play eclipse from your project directory
  3. refresh your eclipse project
like image 5
kwikness Avatar answered Oct 07 '22 14:10

kwikness