当前位置: 首页 > 工具软件 > Play-Mongo > 使用案例 >

PLAY框架

柴宏阔
2023-12-01

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

 类似资料: