Reputation: 131
I am following the play tutorial and I am stuck at roughly 9 mins. The routes file is not getting resolved I did the same thing as shown in the tutorial but still doesn't work.
package controllers;
import models.Bar;
import play.core.Router;
import play.data.Form;
import play.mvc;
import play.*;
import play.Routes;
import views.html.indes;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Hello"));
}
public static Result addBar(){
Bar bar = Form.form(Bar.class).bindFromRequest().get();
bar.save();
return redirect(routes)
}
}
Upvotes: 8
Views: 3480
Reputation: 1876
I have experienced this problem every time I change the scala version of my modules. The easiest way to solve this is:
sbt clean compile
Upvotes: 0
Reputation: 804
These steps work for me:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
under project folder.sbt gen-idea
Upvotes: 1
Reputation: 1195
Project Structure -> Modules -> Dependencies -> + -> JAR or directories -> target/scala-#.##/classes_managed
Marking this directory as Sources Root/Generated Sources Root did not work for me, as mentioned in some other S/O posts
Upvotes: 6
Reputation: 131
It was localhost:9000 itself. I dint try running the server again. Actually the code is not able to identify the routes file which is under conf. I am just trying to replicate whatever is shown in the tutorial but it's not happening!
Upvotes: 2
Reputation: 20182
Based on the information you provided, you need to use the following URL:
localhost:9000
not localhost:/9000. The URL above should trigger the index method (inside the Application controller) to be called. Based on the implementation you shared, it will result in the index template to be used to render the view (with a 200 HTTP response). Make sure that you have index.scala.template in the views directory.
Upvotes: -2