Showing posts with label Play Framework. Show all posts
Showing posts with label Play Framework. Show all posts

Thursday, October 26, 2017

How to transform Play project as Eclipse project

To transform a new Play project into Eclipse workspace.
the following steps can be followed.

1. navigate into the play project root directory. eg. C:\my-play-project

2. add the following plugin into the end of project/plugins.sbt

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.2")



3. add the following configuration into the end of build.sbt

EclipseKeys.preTasks := Seq(compile in Compile, compile in Test)
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java  
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources) 


Wednesday, October 25, 2017

How to create new Play Java project

1. make sure sbt is installed in your OS
2. create a new folder, eg. "my-play-project"
3. open command prompt, and navigate to the newly create folder
4. in the command prompt, type "sbt new playframework/play-java-seed.g8"
  a) enter project name
  b) enter organization
  c) enter scala version
  d) enter play version
  e) enter sbt version

Saturday, June 24, 2017

How to pass date type parameter in a restful service

In certain use case, we might need to pass date type parameter from service consumer to service provider.
But date as a object is not allowed to transfer via http.

The are only 2 additional steps to resolve this problem
1. at consumer side, convert the date object to long value
2. at provider side, convert the long value back to date object.

in Javascript / Play / SpringBoot consumer, convert the date object to long value

new Date().getTime();



in Play / SpringBoot provider, convert the long date value to date object.

new Date( dateValueInLong );




Done!!



Wednesday, March 29, 2017

How to convert DBCursor to JsonNode in Play

The code below only applicable when using mongoDB and Play framework together.


com.mongodb.util.JSON json =new JSON();
String serializedCursor = json.serialize(cursor);

com.fasterxml.jackson.databind.JsonNode jsonData = play.libs.Json.parse(serializedCursor);




Done!!

Wednesday, February 22, 2017

How to setup Eclipse for Play framework

1. open <play-project-home>\project\plugins.sbt (c:\play-java\project\plugins.sbt)
    add the following line.


addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")


2. Open <play-project-home>\build.sbt
    add the following lines

EclipseKeys.preTasks := Seq(compile in Compile)

EclipseKeys.projectFlavor := EclipseProjectFlavor.Java

EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources) 


3. restart the play sbt console, so that sbt performs update for the new plugins.

4. in sbt console, type "eclipse"

5. import the new project into eclipse workspace
    File > Import > Existing Projects into Workspace > Next > Select root directory > browse <play-project-home>, Finish.

source: https://www.playframework.com/documentation/2.5.x/IDE



Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...