Play Framework介紹:使用Eclipse開發(fā)和調(diào)試
轉(zhuǎn)換成Eclipse項目
- 啟動命令行,輸入play new <項目名>,Play會在當(dāng)前路徑下創(chuàng)建項目。
- 輸入play eclipsify <項目名>,Play會在項目目錄中創(chuàng)建eclipse需要的配置文件,將其轉(zhuǎn)換成eclipse項目。
- 在eclipse中導(dǎo)入創(chuàng)建的項目。
調(diào) 試
Play轉(zhuǎn)換eclipse項目時,在eclipse目錄中生成了三個啟動配置:
- JPDA:連接到已經(jīng)啟動的Play Server,實現(xiàn)alive調(diào)試
- helloworld:本地運行
- Test:測試
選中它們,右鍵執(zhí)行Run As,即可完成相應(yīng)的任務(wù)。
本地調(diào)試
直接Debug As 執(zhí)行helloworld會報錯:
Error occurred during initialization of VM
agent library failed to init: jdwp
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
需要:
打開helloworld.launch,找到
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -Dplay.debug=yes -Dplay.id= -Dapplication.path …/>
將-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n 去掉。
然后Debug As,即可成功啟動調(diào)試。附加Play源碼后,即可調(diào)試Play本身。
原文鏈接:http://www.cnblogs.com/Chaos/archive/2011/04/16/2018444.html
【編輯推薦】