Normally, I think that the activator is used to do the Play Framework. However, I would like to use sbt to write the settings myself.
** I get an error with Scala 2.10. This time I will use 2.11.8. ** **
I will write with reference to this page. Play Framework 2 tutorial without Activator
sbt.version=0.13.15
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.15")
name := "my-first-app-without-activator"
version := "1.0"
scalaVersion := "2.11.8"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
Since we will use it in Java this time, set enablePlugins to PlayJava. When using with Scala, replace it with PlayScala.
Application.java
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
public class Application extends Controller {
public Result index() {
return ok("hello");
}
}
GET / controllers.Application.index()
It seems that it should be made for the time being.
$ touch conf/application.conf
The contents are empty.
$ sbt run
If the following is displayed, it is OK.
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
Access (http: // localhost: 9000) and you should see "hello".
Recommended Posts