play 들어가기
play 1일차
Play framework에 대하여
- play framework은 java enterprise edition(JAVA J2EE) API를 가반으로 하지 않는다.
- 선언적인 application URL 구조 설정
- HTTP와 자연스러운 scala API간의 type safe한 mapping
- type safe template 문법
- 웹 브라우저에서 페이지를 다시 로딩할 때 변경된 코드가 실시간으로 반영됨
- 영속성, 보안, 국제화를 지원하는 fullstack web framework이다.
Play2 설치하기
play project생성하는 방법으로는 2가지 activator를 통하거나. sbt giter8 를 통해서 할 수 있다.
- activator로 play project생성하기
activator를 설치 해야 하며 mac에서는 brew를 통해 설치 하면 된다.
brew update
brew install activator
//설치된 경로는/usr/local/Cellar 이 곳에 설치가 된다.
activator로 play project 생성하기
sslee > activator new sslee-play
Fetching the latest list of templates...
Browse the list of templates: http://lightbend.com/activator/templates
Choose from these featured templates or enter a template name:
1) minimal-akka-java-seed
2) minimal-akka-scala-seed
3) minimal-java
4) minimal-scala
5) play-java
6) play-scala
(hit tab to see a list of all templates)
> 6
OK, application "sslee-play" is being created using the "play-scala" template.
To run "sslee-play" from the command line, "cd sslee-play" then:
/Users/sslee/work/temp/sslee-play/activator run
To run the test for "sslee-play" from the command line, "cd sslee-play" then:
/Users/sslee/work/temp/sslee-play/activator test
To run the Activator UI for "sslee-play" from the command line, "cd sslee-play" then:
/Users/sslee/work/temp/sslee-play/activator ui
이렇게 하면 play project template 형태로 생성된다.
eclipse IDE 로 project를 가져 오려면 sbt eclipse plugin를 설정해야 한다.
sbt 의 global설정으로 해도 되고, 해당 project에만 설정해도 된다.
~/.sbt/1.0/plugins/plugins.sbt에 다음을 추가 하면 된다.
//eclipse plugin 추가
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
//해당 project에서 sbt로 해당 명령어로 eclipse project로 만든다.
sbt
eclipse with-source=true
play directory 구조
app - application 소스 코드
conf - 설정 파일과 데이터들
project - project build 관련 파일들
public - 공개적으로 접근 가능한 파일들 js,css 등
test - test
application 실행
activator 로 console로 실행하면 되며,console로 redering를 직접 test할 수 도 있다.
activator run
play console
activator를 이용하여 interactive mode로 실행가능 하며, console명령으로 scala console를 실행 할 수 도 있다.
activator //대화형실행
compile //compile
console //scala console 실행