Tomcat 启动 Debug模式

如果debug启动遇到如下错误:

ERROR: transport error 202: gethostbyname: unknown host
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:750]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)

则应该检查本地的hosts文件, 看127.0.0.1是不是被注掉了.

 

 

 

在%CATALINA_HOME%\bin\startup.bat中添加以下任意一行配置: 
SET JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n 

SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787 

启动tomcat后,在控制台显示以下内容表示配置成功: 
Listening for transport dt_socket at address: 8787

 

在Spring Boot结合Maven的项目中, 如果要对embedded tomcat进行debug, 则需要在POM文件中加入以下内容

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <!-- enable remote debug for embed jvm, the following configuration suspend the process until a debugger has joined on port 8787 -->
          <jvmArguments>
            -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787     </jvmArguments>         </configuration>       </plugin>   </plugins> </build>

 

转载于:https://www.cnblogs.com/haibinyuan/p/4886396.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值