開發過程中有時需要同時debug兩個play工程,而play debug的默認端口爲9999,不能指定修改。
研究了一下,通過修改play的啓動腳本實現了允許指定debug端口啓動工程。
play版本:2.2.6
方法:
1、windows平臺
用記事本打開play安裝目錄下的play.bat
找到:setDebug這行附近
#原配置代碼
:setDebug
JPDA_PORT=9999
修改爲
#新配置代碼
:setDebug
set JPDA_PORT=%~3
if "%~3" == "" set JPDA_PORT=9999
2、unix平臺
vim /play安裝目錄/play
#原配置代碼
if test "$1" = "debug"; then
JPDA_PORT="9999"
shift
fi
#修改爲新配置代碼
if test "$1" = "debug"; then
if test "$3" = "" then
JPDA_PORT="9999"
else
JPDA_PORT=$3
fi
shift
fi
即啓動時默認debug端口仍爲9999,如果輸入第三個參數,則使用第三個參數作爲debug的端口
啓動示例:
play debug "run 9001" 9998
這時debug的端口爲9998
web訪問端口爲9001
這樣就實現了本地同時啓動多個play項目,同時debug多個play項目。