开发过程中有时需要同时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项目。