JSON

Play 2.0: Akka, Rest, Json and dependencies

字号+ 作者:H5之家 来源:H5之家 2017-05-01 10:01 我要评论( )

Play 2.0: Akka, Rest, Json and dependencies ,ITPUB论坛-中国最专业的IT技术社区

I've been diving more and more into scala the last couple of months. Scala together with the "Play Framework" provides you with a very effective and quick development environment (as soon as you've grasped the idiosyncrasies of the Scala language, that is).

The guys behind the Play framework have been hard at work at the new version Play 2.0. In Play 2.0 scala plays a much more important role, and especially the complete build process has been immensely improved. The only problem so far, I've encountered with Play 2.0 is the lack of good documentation. The guys are hard at work at updating the wiki, but its often still a lot of trial and error to get what you want. Note though, that often this isn't just caused by Play, I also sometimes still struggle with the more exotic Scala constructs ;-)

In this article, I'll give you an introduction into how you can accomplish some common tasks in Play 2.0 using Scala. More specifically I'll show you how to create an application that:

  • uses sbt based dependency management to configure external dependencies
  • is edited in Eclipse (with the Scala-ide plugin) using the play eclipsify command
  • provides a Rest API using Play's routes
  • uses Akka 2.0 (provided by the Play framework) to asynchronously call the database and generate Json (just because we can)
  • convert Scala objects to Json using the Play provided Json functionality (based on jerkson)

    I won't show the database access using Querulous, if you want to know more about that look at thisarticle. I'd like to convert the Querulous code to using Anorm. But since my last experiences with Anorm were, how do I put this, not convincingly positive, I'm saving that for a later day.

    Creating an application with Play 2.0

    Getting up and running with Play 2.0 is very easy and is well documented, so I won't spent too much time on this. For complete instruction see the Play 2.0 Wiki. To get up and running, after you you have downloaded and extracted Play 2.0, take the following steps:


    Read the rest of the article at the following URL:

    Java Code Geeks: Play 2.0: Akka, Rest, Json and dependencies


     

  • 1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

    相关文章
    • Spring MVC Rest 学习 一

      Spring MVC Rest 学习 一

      2017-03-12 11:04

    • WordPress REST API 文章编辑漏洞

      WordPress REST API 文章编辑漏洞

      2017-02-10 18:01

    • WCF简单教程(11) REST调用

      WCF简单教程(11) REST调用

      2016-12-15 10:00

    • Resteasy转换JAXB和json

      Resteasy转换JAXB和json

      2016-11-14 12:00

    网友点评
    "