tomcat+myeclipse配置远程调试

作为一名开发人员多多少少会遇到各种问题,在众多问题中或许你也会遇到:在本地都运行的好好的,可是发布到服务器后怎么就出问题了呢?出现这种问题的原因有很多种,可到底是什么原因引起的呢?我们开发过程中通常都是通过myeclipse的debug来查找原因,总不可能在服务器上安装myeclipse来调试程序吧?那怎么办?没关系,还好有jpda(全称JavaTM Platform Debugger Architecture)这个东东,需要在tomcat的启动文件(startup.bat)中配置jpda,为了不修改原有的文件,我们新增一个startup_debug.bat,内容如下:

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 895392 2010-01-03 14:02:31Z kkolinko $
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome

set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"

rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec

rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=8000
set JPDA_SUSPEND=n

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

:end

内容与startup.bat几乎一致,标黑的脚本为新增的脚本,启动时启动startup_debug.bat即可

参数解释:

jpda_transport=dt_socket(JPDA front-end和back-end之间的传输方法。dt_socket表示使用套接字传输。)

jpad_address=8000(JVM在8000端口上监听请求。)

jpda_suspend=n(n表示直接启动监听端口和JVM,y表示启动的JVM会暂停等待,直到调试器连接上。)

 

配置本地的myeclipse

 右键需要调试的工程debug asdebug configurationsnew 一个java remote application,填写如下图,信息填写正确后,点击debug即可进行远程调试了。

 105143_YzL6_1753237.jpg

 

 注意:1、调试时需要保持本地代码和服务器上代码一致

          2、确认防火墙关闭

转载于:https://my.oschina.net/u/1753237/blog/274739

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值