18 มิ.ย. 2555

Play Framework ทำเว็บด้วย Java กัน

  1. Download file play framework จาก http://www.playframework.org/ แตก zip ไฟล์ที่ได้ไว้ใน  Directory นึง

  2. Set Envoirment path โดยใส่ path ของ Directory Play framework ที่เรา แตก zip ไว้ restart เครื่อง
  3. สร้าง Application โดยทำการเปิดหน้าต่าง command line หรือ cmd นั่นเอง พิมพ์
    "play new ชื่อProject " เมื่อพิมพ์เสร็จแล้วก็จะได้ Folder ที่ข้างในจะมี ส่วนของการทำงานต่างๆโดยจะแบ่งเป็น Folder ดังนี้
    1.   "app/" contains the application’s core, split between models, controllers and views directories. This is the directory where .java source files live.
    2.   "conf/" contains all the application’s configuration files, especially the main appliation.conffile, the routes definition files and the messages files used for internationalization.
    3.   "project/" contains the build scripts. The build system is based on sbt. But a new play application comes with a default build script that will just works fine for our application.
    4.   "public/" contains all the publicly available resources, which includes JavaScript, stylesheets and images directories.
    5.   "test/" contains all the application tests. Tests can be written as JUnit tests. 

  4. เข้าไปใน Folder Project เราพิมพ์ "play" จะขึ้นชื่อ Project มาต่อไปพิมพ์ "run" รอสักพัก ก็จะขึ้นแบบนี้


    ภาพจาก http://www.playframework.org/documentation/2.0.1/JavaTodoList

    ทำการเข้าเมื่อโปรแกรม run เสร็จแล้วที่ http://localhost:9000/




    วันนี้เท่านี้ก่อนนะครับวันหลังจะมาต่อเรื่องการใช้ play ร่วมกับ IDE Eclipse 

ไม่มีความคิดเห็น:

แสดงความคิดเห็น