PLAY框架

PLAY2.0框架快速入门

//

http://www.playframework.com/

http://www.playframework.org/已经被废弃

Play Version:2.3.1

The Play team is pleased to announce the release of Play 2.3.0!


What’s new inPlay2.3


  1. Introducing the activator command. You can useactivator exactly like you would use play, but Activator brings new features too. (More about the Activator change.)

  2. Better tooling for static assets.Play now uses sbt-web which gives faster asset processing, more features, and better extensibility.

  3. Support forJava 8 (and continued support for Java 6 and 7).

  4. BetterJava performance. Simple Java controllers give 40–90% better throughput. (Thanks toYourKit for sponsoring licenses.)

  5. Support forScala 2.11 (and continued support for Scala 2.10).

  6. Anorm enhancements: SQL string interpolation, multi-value parameters, new types, and more.

  7. Web Services enhancements: separate client, SSL configuration, and more.

  8. Play templates have become Twirl templates: separate project, new sbt plugin, still excellent integration withPlay

  9. Actors for WebSockets

  10. Custom SSLEngine for HTTPS

  11. Asset performance: faster serving, better caching.

  12. One Result to rule them all: all the result types which were deprecated in 2.2 are now gone and only Result remains.

  13. Lots of bug fixes. :)


For details see the Play2.3 Highlights and thePlay2.3 Migration Guide.



typesafe activator 1.2.3

installing

下载完整的zip文件,而不是min。

 There are three ways to run activator:


 1. Recommended: try `activator ui` to create a project in the UI
 2. Use `activator new` to create a project on the command line
 3. Load an existing project by re-running activator in a project directory


activator ui


[error] p.nettyException - Exception caught in Netty
java.lang.IllegalArgumentException: invalid version format

http://stackoverflow.com/questions/21667254/play-framework-2-2-1-https-fails-on-connection-attempt

keytool -genkey -alias MyKey -keyalg RSA -keysize 2048 -keystore keystore.jks
play -Dhttps.port=9443 -Dhttps.keyStore=keystore.jks -Dhttps.keyStorePassword=password run
上面说使用这个命令就解决了问题。

我试过了

activator new my-first-app play-java
提示说找不到template,因为无法去访问某个地址。
于是设置了~/.activator/activatorconfig.txt
<span style="font-size:14px;"><span style="font-size:14px;"># This are the proxy settings we use for activator
-Dhttp.proxyHost=localhost
-Dhttp.proxyPort=8580
# Here we configure the hosts which should not go through the proxy.  You should include your private network, if applicable.
-Dhttp.nonProxyHosts="localhost|127.0.0.1|davidzhang-pc|192.168.0.104"</span></span>

cd my-first-app
activator
$run
出错
org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:9000
stackflow里面提到了解决方法,不能使用9000端口!
$run 9001

<span style="font-size:14px;"><span style="font-size:14px;">[my-first-app] $ run 9001

--- (Running the application from SBT, auto-reloading is enabled) --

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9001

(Server started, use Ctrl+D to stop and go back to the console...)</span></span>


Available Template

<span style="font-size:14px;"><span style="font-size:14px;">E:\Workspaces\play>activator list-templates

Fetching the latest list of templates...

七月 14, 2014 7:30:58 下午 com.amazonaws.http.HttpClientFactory createHttpClient

信息: Configuring Proxy. Proxy Host: localhost Proxy Port: 8xxx
Featured Seed Templates:
  minimal-java
  minimal-scala
  play-java
  play-scala

Featured Tutorial Templates:
  hello-akka
  hello-scala
  hello-slick-2.1
  reactive-maps
  reactive-stocks

Other Seed Templates:
  gilt-lib
  just-play-java
  just-play-scala
  play-silhouette-seed
  play-silhouette-seed-slick
  webjars-sample-play2

Other Tutorial Templates:
  activator-akka-cassandra
  activator-akka-scala-guice
  activator-akka-spray
  activator-akka-tracing
  activator-gilt-app
  activator-play-autosource-reactivemongo
  activator-scalding
  activator-spray-twitter
  agile-scala-android-example
  akka-callcenter
  akka-camel-cxf-weather
  akka-circuit-breaker-java
  akka-cluster-sharding-scala
  akka-clustering
  akka-custom-dispatcher
  akka-distributed-workers
  akka-distributed-workers-java
  akka-java-spring
  akka-persistence-event-sourcing
  akka-sample-camel-java
  akka-sample-camel-scala
  akka-sample-cluster-java
  akka-sample-cluster-scala
  akka-sample-fsm-java-lambda
  akka-sample-fsm-scala
  akka-sample-main-java
  akka-sample-main-java-lambda
  akka-sample-main-scala
  akka-sample-multi-node-scala
  akka-sample-persistence-java
  akka-sample-persistence-java-lambda
  akka-sample-persistence-scala
  akka-sample-remote-java
  akka-sample-remote-scala
  akka-scala-spring
  akka-spray-websocket
  akka-stream-scala
  akka-supervision
  akka-supervision-java-lambda
  akka-with-esper
  angular-seed-play
  atomic-scala-examples
  config-guice-akka-spray
  dart-akka-spray
  eventual
  finagle-quickstart
  hazelcast-spray-akka
  hello-akka-java8
  hello-apache-spark
  hello-play-2_3-scala
  hello-play-backbone
  hello-play-java
  hello-play-scala
  hello-sbt
  hello-scala-2_11
  hello-scala-eclipse
  hello-scaladin
  hello-scaloid
  hello-slick
  lolcode-dsl
  macroid-akka-pingpong
  macwire-activator
  matthiasn-sse-chat-template
  mirror
  modern-web-template
  play-2.3-highlights
  play-akka-angular-websocket
  play-akka-cluster-sample
  play-angular-require-seed
  play-angularjs-webapp-seed
  play-bigpipe-with-rxjava-hystrix
  play-cake
  play-example-form
  play-guice
  play-hbase
  play-iteratees
  play-java-spring
  play-mongo-knockout
  play-reactive-mongo
  play-scala-backbone-todo
  play-scalatest-subcut
  play-slick
  play-slick-advanced
  play-slick-bootstrap3
  play-slick-quickstart
  play-spring-data-jpa
  play-sqlite
  play-tls-example
  play-web-portal
  play-websocket
  play-yeoman
  play2-crud-activator
  play2bars-squeryl
  PlayStartApp
  rabbitmq-akka-stream
  reactive-gen-easymda
  reactive-java8-play
  reactive-maps-java
  reactive-orientation
  reactive-scales
  reactive-stocks-java8
  realtime-search
  redis-twitter-clone
  sbt-github-project-template
  sbt-jmh-seed
  sbt-native-package-server
  scala-phantom-types
  scala-testing
  scaldi-akka-example
  scaldi-play-example
  scalikejdbc-activator-template
  securesocial-slick-bootstrap3-sample
  six-minute-apps
  slick-android-example
  slick-codegen-customization-example
  slick-codegen-example
  slick-direct
  slick-direct-2.1
  slick-multidb
  slick-multidb-2.1
  slick-plainsql
  slick-plainsql-2.1
  slick-testkit-example
  slick-testkit-example-2.1
  snakeyard
  spark-in-action
  spark-streaming-scala
  spark-streaming-scala-akka
  spark-workshop
  spray-actor-per-request
  sse-chat-template-java
  tcp-async
  template-template
  test-patterns-scala
  tweetmap-java8
  tweetmap-workshop
  vaadin-in-akka</span></span>


$compile

$console

scalasdk

使用IDE调试debug play app:

step1:activator your application with a debug port

activator -jvm-debug 9999 

step2:add a debug configuration in IDE

and in Eclipse right-click on the project and select Debug AsDebug Configurations. In the Debug Configurations dialog, right-click on Remote Java Application and select New. Change Port to 9999 and click Apply. From now on you can click on Debug to connect to the running application. Stopping the debugging session will not stop the server.

step3:run app listending a port

run  9001

step4:add breakpoints in play project app sourcecode

step5:input a url in a browser, test your web app:

http://localhost:9001

///

Scala + Play + Sbt + Protractor = One Build

========================

一位朋友分享的项目

http://my.oschina.net/smeite/blog/184350

https://github.com/smeite/smeite

食美特的项目地址在 https://github.com/smeite/smeite  已经有好几个月没有更新了,感兴趣的朋友可以去玩玩。整个网站采用playframework2.1+slick+mysql做的架构,有 52个 数据表,前端js使用的是seajs 2.1 和淘宝前端aralejs javascript框架。网站的访问速度和压力都非常不错,做了很多优化,更兴趣的朋友可以去github上看看。 

//

Play源代码分析:Server启动过程(play1.x)

Typesafe Stack 2.0发布

playframework源代码:
https://github.com/playframework/playframework

-------------------------------------------

这是我要的模板

https://typesafe.com/activator/template/reactive-maps-java

MVC应用程序模型 - 7 - app/controllers - 8 - app/models - 8 - app/views - 8 - 请求生命周期 - 8 - 标准应用程序布局layout - 9 - app目录 - 9 - public目录 - 10 - conf目录 - 10 - lib目录 - 11 - 开发生命周期 - 11 - 连接到java调试器 - 12 - 类增强Enhancement - 13 - 02.HTTP路由 - 13 - 关于REST - 14 - routes文件语法 - 14 - HTTP方法 - 15 - URI范示 Pattern - 15 - Java调用定义 - 17 - 把404当作action来用 - 17 - 指派静态参数 - 17 - 变量和脚本 - 18 - 路由优先级 - 18 - 服务器静态资源 - 18 - staticDir: mapping - 18 - staticFile: mapping - 19 - URL 编码 - 19 - 反转路由:用于生成某些URL - 19 - 设置内容风格(CSS) - 20 - HTTP 内容协商 negotiation - 21 - 从http headers开始设置内容类型 - 21 - 定制格式 - 22 - 03.控制器 - 23 - 控制器概览 - 23 - 获取http参数 - 24 - 使用params map - 25 - 还可以从action方法签名实现转换 - 25 - 高级HTTP Java绑定 - 26 - 简单类型 - 26 - Date类型 - 26 - Calendar日历 - 27 - File - 27 - 支持类型的数组或集合 - 28 - POJO对象绑定 - 29 - JPA 对象绑定 - 30 - 定制绑定 - 30 - @play.data.binding.As - 30 - @play.data.binding.NoBinding - 31 - play.data.binding.TypeBinder - 31 - @play.data.binding.Global - 32 - 结果类型 - 32 - 返回一些文本类型的内容 - 33 - 返回一个JSON字符串 - 33 - 返回一个XML字符串F - 34 - 返回二进制内容 - 34 - 作为附件下载文件 - 34 - 执行一个模板 - 35 - 跳转到其他URL - 36 - Action链 - 36 - 定制web编码 - 37 - 拦截器 - 38 - @Before - 38 - @After - 39 - @Catch - 40 - @Finally - 41 - 控制器继承 - 42 - 使用@With注释添加更多的拦截器 - 42 - Because Java does not allow multiple inheritance, it can be very limiting to rely on the Controller hierarchy to apply interceptors. But you can define some interceptors in a totally different class, and link them with any controller using the @With annotation.由于java不允许多继承,通过控制器继承特点来应用拦截器就受到极大的限制。但是我们可以在一个完全不同的类里定义一些拦截器,然后在任何控制器里使用@With注释来链接他们。 - 42 - Session和Flash作用域 - 42 - 04.模板引擎 - 43 - 模板语法 - 43 - Expressions: ${…} - 44 - Template decorators : #{extends /} and #{doLayout /} - 44 - Tags: #{tagName /} - 45 - Actions: @{…} or @@{…} - 46 - Messages: &{…} - 46 - Comment: *{…}* - 46 - Scripts: %{…}% - 46 - Template inheritance继承 - 47 - 定制模板标签 - 48 - 检索tag参数 - 48 - 调用标签体 - 48 - 格式化特定标签 - 49 - 定制java标签 - 49 - 标签命名空间 - 50 - 在模板里的Java对象扩展 - 51 - 创建定制扩展 - 52 - 模板里可以使用的保留对象 - 52 - 05.用play验证http数据
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值