Browse Source

Play2-scala now uses Play 2.6.0 (#2904)

* Play2-scala now uses Play 2.6.0

* Play2-scala now uses Play 2.6.0

* Play2-scala now uses Play 2.6.0

* Fixes 'java.lang.RuntimeException: No application loader is configured.' as per https://github.com/playframework/playframework/issues/6646
Marco F 8 years ago
parent
commit
0c85f07f27

+ 7 - 7
frameworks/Scala/play2-scala/play2-scala/app/controllers/Application.scala

@@ -1,24 +1,24 @@
 package controllers
 package controllers
 
 
-import javax.inject.Singleton
-import akka.util.CompactByteString
-import play.api.http.HttpEntity.Strict
+import javax.inject.{ Inject, Singleton }
+
 import play.api.mvc._
 import play.api.mvc._
 import play.api.libs.json.Json
 import play.api.libs.json.Json
 import play.mvc.Http
 import play.mvc.Http
 
 
 @Singleton
 @Singleton
-class Application extends Controller {
-  val header = ResponseHeader(OK, Map(Http.HeaderNames.SERVER -> "EXAMPLE"))
+class Application @Inject() (cc: ControllerComponents)
+extends AbstractController(cc) {
+
   implicit val helloWorldWrites = Json.writes[HelloWorld]
   implicit val helloWorldWrites = Json.writes[HelloWorld]
 
 
   def getJsonMessage = Action {
   def getJsonMessage = Action {
     val helloWorld = HelloWorld(message = "Hello, World!")
     val helloWorld = HelloWorld(message = "Hello, World!")
-    Result(header, Strict(CompactByteString(Json.toJson(helloWorld).toString()), Some("application/json")))
+    Ok(Json.toJson(helloWorld)).withHeaders(Http.HeaderNames.SERVER -> "Play Framework")
   }
   }
 
 
   val plaintext = Action {
   val plaintext = Action {
-    Result(header, Strict(CompactByteString("Hello, World!"), Some("text/plain")))
+    Ok("Hello, World!").withHeaders(Http.HeaderNames.SERVER -> "Play Framework")
   }
   }
 }
 }
 
 

+ 7 - 3
frameworks/Scala/play2-scala/play2-scala/build.sbt

@@ -1,7 +1,11 @@
 name := "play2-scala"
 name := "play2-scala"
 
 
-version := "2.5.14"
+version := "2.6.0"
 
 
-scalaVersion := "2.11.8"
+scalaVersion := "2.11.11"
+
+val root = (project in file(".")).enablePlugins(PlayScala)
+
+libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.0"
+libraryDependencies += guice
 
 
-val root = (project in file(".")).enablePlugins(PlayScala)

+ 4 - 14
frameworks/Scala/play2-scala/play2-scala/conf/application.conf

@@ -8,7 +8,7 @@
 # This must be changed for production, but we recommend not changing it in this file.
 # This must be changed for production, but we recommend not changing it in this file.
 #
 #
 # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
 # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
-play.crypto.secret = "RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59"
+play.http.secret.key = "RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59"
 
 
 # The application languages
 # The application languages
 # ~~~~~
 # ~~~~~
@@ -51,16 +51,6 @@ play.server {
 
 
 akka {
 akka {
   log-dead-letters = off
   log-dead-letters = off
-  actor {
-    default-dispatcher {
-      fork-join-executor {
-        parallelism-min = 1
-        parallelism-factor = 0.5  # don't overuse CPU by context swiching, thread contention & spinning
-        parallelism-max = 16
-      }
-    }
-    default-mailbox {
-      mailbox-type = "akka.dispatch.SingleConsumerOnlyUnboundedMailbox"
-    }
-  }
-}
+}
+
+play.filters.enabled=[]

+ 2 - 10
frameworks/Scala/play2-scala/play2-scala/conf/routes

@@ -1,10 +1,2 @@
-# Routes
-# This file defines all application routes (Higher priority routes first)
-# ~~~~
-
-# Home page
-GET     /json                           @controllers.Application.getJsonMessage
-GET     /plaintext                      @controllers.Application.plaintext
-
-# Map static resources from the /public folder to the /assets URL path
-GET     /assets/*file                   controllers.Assets.at(path="/public", file)
+GET     /json       controllers.Application.getJsonMessage
+GET     /plaintext  controllers.Application.plaintext

+ 1 - 1
frameworks/Scala/play2-scala/play2-scala/project/build.properties

@@ -1 +1 @@
-sbt.version=0.13.11
+sbt.version=0.13.15

+ 1 - 1
frameworks/Scala/play2-scala/play2-scala/project/plugins.sbt

@@ -2,4 +2,4 @@
 logLevel := Level.Warn
 logLevel := Level.Warn
 
 
 // Use the Play sbt plugin for Play projects
 // Use the Play sbt plugin for Play projects
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.14")
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.0")