从cmd启动tomcat时如何在eclipse中进入调试模式
How to enter debug mode in eclipse when launching tomcat from cmd
我正在使用 apache-tomcat-8.5.24 并且在 Eclipse 中配置了工作区并且 tomcat 工作正常。
虽然我需要进行一些调试,但我不知道如何使用 cmd 中的 tomcat 运行 在 Eclipse 中进入调试模式?我过去做过几次,但我总是从 IDE.
以调试模式启动 tomcat
您必须在 tomcat 上启用远程调试,为此需要在 tomcat startup.sh 或 tomcat.start.sh 中添加以下 catalina 属性 或在任何地方添加 tomcat 启动属性:
CATALINA_OPTS="$CATALINA_OPTS
-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
然后重启tomcat.
完成后,需要打开eclipse,去"Debug --> Debug Configurations -- type in the search box "远程java应用程序”,新建,然后select 您要调试的 module/java 项目,并提供与上述命令中相同的端口号(即上例中的 8787)。然后应用并启动。
虽然其他答案可能解决了某些人的问题,但并没有解决我的问题。尽管我遵循并解决问题的方法是:
首先你启动tomcat(所有服务起来),然后你在eclipse中启动调试模式!!!
对于 tomcat 因为我使用 catalina.bat jpda run
开始我的 tomcat 我只是编辑它并按如下方式使用它:
catalina.bat jpda run - agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
对于日食:
1)In Eclipse’s menu, select Run > Debug Configurations…
2)A new Debug Configurations window will appear
3)In the list on the left, select Remote Java Application. Don’t worry
too much about the word “remote” here. It just means that the JVM
process can either be on the local machine or another machine across
the network.
4)Select New in the context menu (you can either right click to see
the option for it, or select the icon above the list)
5)A new Remote Java Application debug configuration window will appear
6)Change the Name field to say “Tomcat (local)”, or the name of your
web application, your choice. The name you put here can be anything,
but shorter is better because the name will show up in menus.
Eclipse Run Configuration for a separate Tomcat JVM
There are at least three subtabs of configuration: Connect, Source,
and Common. Under the Connect subtab, there is a Project field. Select
the Eclipse project that represents the code you want to debug. For
instance, if you want to debug your webapp, select your webapp’s
Eclipse project here.
All of the other default settings should be fine. You should probably
look through the settings to see if you would like to change any
options, just beware of changing settings if you aren’t sure what the
effect will be. Make sure that the port number you’re setting in the
Connect subtab is the same port number you configured your Tomcat
JVM’s debug server to listen on.
Click Apply, then click Debug. At that point, your Eclipse’s debugger
will connect to your Tomcat JVM’s debug server. Next, switch to the
Eclipse Debug perspective. In Eclipse’s menu, select Window > Open
Perspective > Debug.
我正在使用 apache-tomcat-8.5.24 并且在 Eclipse 中配置了工作区并且 tomcat 工作正常。
虽然我需要进行一些调试,但我不知道如何使用 cmd 中的 tomcat 运行 在 Eclipse 中进入调试模式?我过去做过几次,但我总是从 IDE.
以调试模式启动 tomcat您必须在 tomcat 上启用远程调试,为此需要在 tomcat startup.sh 或 tomcat.start.sh 中添加以下 catalina 属性 或在任何地方添加 tomcat 启动属性:
CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
然后重启tomcat.
完成后,需要打开eclipse,去"Debug --> Debug Configurations -- type in the search box "远程java应用程序”,新建,然后select 您要调试的 module/java 项目,并提供与上述命令中相同的端口号(即上例中的 8787)。然后应用并启动。
虽然其他答案可能解决了某些人的问题,但并没有解决我的问题。尽管我遵循并解决问题的方法是:
首先你启动tomcat(所有服务起来),然后你在eclipse中启动调试模式!!!
对于 tomcat 因为我使用 catalina.bat jpda run
开始我的 tomcat 我只是编辑它并按如下方式使用它:
catalina.bat jpda run - agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
对于日食:
1)In Eclipse’s menu, select Run > Debug Configurations…
2)A new Debug Configurations window will appear
3)In the list on the left, select Remote Java Application. Don’t worry too much about the word “remote” here. It just means that the JVM process can either be on the local machine or another machine across the network.
4)Select New in the context menu (you can either right click to see the option for it, or select the icon above the list)
5)A new Remote Java Application debug configuration window will appear
6)Change the Name field to say “Tomcat (local)”, or the name of your web application, your choice. The name you put here can be anything, but shorter is better because the name will show up in menus.
Eclipse Run Configuration for a separate Tomcat JVM
There are at least three subtabs of configuration: Connect, Source, and Common. Under the Connect subtab, there is a Project field. Select the Eclipse project that represents the code you want to debug. For instance, if you want to debug your webapp, select your webapp’s Eclipse project here.
All of the other default settings should be fine. You should probably look through the settings to see if you would like to change any options, just beware of changing settings if you aren’t sure what the effect will be. Make sure that the port number you’re setting in the Connect subtab is the same port number you configured your Tomcat JVM’s debug server to listen on.
Click Apply, then click Debug. At that point, your Eclipse’s debugger will connect to your Tomcat JVM’s debug server. Next, switch to the Eclipse Debug perspective. In Eclipse’s menu, select Window > Open Perspective > Debug.