-
2019-01-02 08:23:21
第一种
命令行
java –jar xxx.jar --debug
第二种
在application.properties中设置属性
debug=true
第三种
在启动上面设置Run Configurations…
在VM arguments中添加 –Ddebug
更多相关内容 -
Spring Boot开启debug模式
2018-09-30 02:37:22使用IDEA开发环境时,采用Spring Boot框架开启debug模式的流程 -
springboot debug模式启动
2022-02-14 09:23:32我们都知道,在idea或者eclipse等IDE工具中,都有debug模式启动,但是这种启动是针对我们自己开发的代码的一种开发运行模式,而springboot提供的debug启动模式是对springboot框架信息打印的模式,需要在配置文件中...我们都知道,在idea或者eclipse等IDE工具中,都有debug模式启动,但是这种启动是针对我们自己开发的代码的一种开发运行模式,而springboot提供的debug启动模式是对springboot框架信息打印的模式,需要在配置文件中配置
debug=true
增加后,我们再次启动springboot项目,会发现在控制台打印信息增加了许多
截图中的positive matches下边打印的是springboot启动过程中,自动配置生效的组件,可以看到有aop自动配置,cache缓存自动配置等信息
还有未生效的自动匹配信息,例如ActiveMQAutoConfiguration消息队列未成功自动配置,列举了原因:
开启ActiveMQAutoConfiguration自动配置需要@ConditionalOnClass存在某个类的条件,而此处需要 javax.jms.ConnectionFactory这个类,在我们启动的环境中不存在,所以自动匹配无法生效。Did not match: - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)
debug模式下,可以很好的帮助我们分析自动装配的情况。
-
idea SpringBoot 项目Debug模式启动缓慢
2019-09-25 16:41:27本地测试springboot使用jar包部署时(容器使用jetty),确认zk是否延迟解注册(通过dubbo-admin查看提供者是否消失) 执行kill命令后,再次debug就不能启动 原因-> 公司内部配置中心依赖本地缓存路径没有权限。 详见...- 这个问题很诡异,在使用kill -15 pid之后产生的
- kill -15 pid 尽可能中止进程
- 本地测试springboot使用jar包部署时(容器使用jetty),确认zk是否延迟解注册(通过dubbo-admin查看提供者是否消失)
- 执行kill命令后,再次debug就不能启动 原因-> 公司内部配置中心依赖本地缓存路径没有权限。 详见解决方法 mac sudo: /etc/sudoers is world writable
- 通过debug启动,完全启动起来需要10+分钟,本以为第一次需要这样,然而…
# 这里启动时间没有包括加载数据库缓存池,自定义敏感词之类的配置等等 2019-09-25 15:14:14.148 [TxId : , SpanId : ] [INFO ] | restartedMain | | o.s.web.context.ContextLoader:285 | Root WebApplicationContext: initialization completed in 273902 ms | [logsend] 2019-09-25 15:17:53.024 [TxId : , SpanId : ] [INFO ] | restartedMain | | com.zaxxer.hikari.HikariDataSource:110 | HikariPool-1 - Starting... | [logsend] 2019-09-25 15:17:58.497 [TxId : , SpanId : ] [INFO ] | restartedMain | | com.zaxxer.hikari.HikariDataSource:123 | HikariPool-1 - Start completed. | [logsend] 2019-09-25 15:18:00.436 [TxId : , SpanId : ] [WARN ] | restartedMain | | com.zaxxer.hikari.HikariConfig:1081 | HikariPool-2 - idleTimeout is close to or more than maxLifetime, disabling it. | [logsend] 2019-09-25 15:18:00.443 [TxId : , SpanId : ] [INFO ] | restartedMain | | com.zaxxer.hikari.HikariDataSource:110 | HikariPool-2 - Starting... | [logsend] 2019-09-25 15:18:01.415 [TxId : , SpanId : ] [INFO ] | restartedMain | | com.zaxxer.hikari.HikariDataSource:123 | HikariPool-2 - Start completed. | [logsend]
- 刚以为是kill命令导致的问题,就一直沿这方方向排查
- 折磨自己半天之后,才百度搜索找到原因
上面是取消断点
下面是忽略/跳过所有断点 - 去除所有断点就正常了,很诡异,原因详见10
- 刚去除是 Java Line Breakpoints 但不能debug是个问题
- 最终原因是断点打到方法上导致的 截图只是示例,实际断点打在业务方法上,本来断点是在第一行
- 也有可能是这个原因导致的
执行 hostname 命令可得 注意修改 /etc/hosts 文件时,ip 与域名之间要换成两个 tab 键 127.0.0.1<两个tab>localhost 替换为$hostname 255.255.255.255<两个tab>broadcasthost ::1<两个tab>localhost 替换为$hostname
参考文章
-
springboot 远程debug
2021-08-31 20:15:04springboot 远程debug
springboot 远程debug
应用:本地打断点,对运行在远程服务器上的程序进行调试
*******************
远程调试
原理:本地jvm程序与远程jvm程序代码保持一致,通过调试协议进行通信
attach 模式:远程服务器暴露端口、开启监听,本地连接远程服务器
listen 模式:本地暴露端口、开启监听,远程应用连接到本地
-Xdebug:开启远程调试 jwdp参数,格式: -Xrunjwdp:name=value,name2=value2,... -agentlib:jwdp:name=value,name2=value2,... jwdp name可选值: transport:远程debug程序连接方式,dt_socket(默认)、dt_shmem(共享内存) server:y(debug服务端)、n(默认,debug客户端) address:server=n时必须设置;server=y时,可不设置 launch:jwdp初始化完成后,启动指定的程序(可选) onthrow:指定异常发生后,开始jwdp的初始化(可选) onuncaught:y(未捕获的异常发生后,开始jwdp的初始化)(可选) n(默认,jwdp正常初始化) stdalloc:n(默认值),可选 By default, the JDWP reference implementation uses an alternate allocator for its memory allocation. If “y”, the standard C runtime library allocator will be used. This option is mainly for testing; use it with care. Deadlocks can occur in this VM if the alternative allocator is disabled strict:n(默认值),可选 If “y”, assume strict JVMDI conformance. This will disable all workarounds to known bugs in JVMDI implementations. This option is mainly for testing and should be used with care. suspend:y(默认值),可选 debug服务端是否等待debug客户端连接上后再启动,y:挂起等待、n:直接启动 If “y”, VMStartEvent has a suspend Policy of SUSPEND_ALL. If “n”, VMStartEvent has a suspend policy of SUSPEND_NONE
debug服务端参数
jdk5及以后:-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 jdk4:-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 jdk3及之前:-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
debug客户端只需要连接服务端的ip:port(5005)即可进行调试
*******************
示例
*************
controller 层
HelloController
@RestController public class HelloController { @RequestMapping("/hello") public String hello(){ int i=1; i+=1; System.out.println(i); return "hello"; } }
项目打包:demo.jar
*******************
attach 模式
demo.jar上传到远程服务器:suspend=n
[root@centos test3]# java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=\*:5005 demo.jar Listening for transport dt_socket at address: 5005 # 远程服务器开启监听端口:5005 # suspend=n,debug服务端不需要等待客户端连接就可以启动 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.5.4) 2021-09-07 20:57:06.135 INFO 7603 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT using Java 16.0.2 on centos with PID 7603 (/usr/java/test3/demo.jar started by root in /usr/java/test3) 2021-09-07 20:57:06.152 INFO 7603 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2021-09-07 20:57:09.843 INFO 7603 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-09-07 20:57:09.908 INFO 7603 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-09-07 20:57:09.909 INFO 7603 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.52] 2021-09-07 20:57:10.256 INFO 7603 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-09-07 20:57:10.256 INFO 7603 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3745 ms 2021-09-07 20:57:12.248 INFO 7603 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2021-09-07 20:57:12.299 INFO 7603 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 8.387 seconds (JVM running for 12.667)
远程服务端:suspend=y
[root@centos test3]# java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=\*:5005 demo.jar Listening for transport dt_socket at address: 5005 # suspend=y:远程服务端开启监听端口,一直处于监听状态,直到debug客户端连接后才会启动
debug客户端:run ==> edit configuration ==> remote jvm debug
设置host、port
点击debug
debug服务端连接成功
本地打断点
发送请求:192.168.57.120:8080/hello
本地代码进入断点
*******************
listen 模式
先开启本地debug(listen模式)
点击debug
demo.jar上传到远程服务器,启动
[root@centos test3]# java -jar -agentlib:jdwp=transport=dt_socket,server=n,address=******:5005,suspend=y demo.jar ******:本地服务器ip server=n:表示远程服务器为debug客户端 server=n时,suspend=y、n启动效果等同 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.5.4) 2021-09-07 21:28:16.162 INFO 7868 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT using Java 16.0.2 on centos with PID 7868 (/usr/java/test3/demo.jar started by root in /usr/java/test3) 2021-09-07 21:28:16.164 INFO 7868 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2021-09-07 21:28:18.888 INFO 7868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-09-07 21:28:18.920 INFO 7868 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-09-07 21:28:18.921 INFO 7868 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.52] 2021-09-07 21:28:19.163 INFO 7868 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-09-07 21:28:19.163 INFO 7868 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2878 ms 2021-09-07 21:28:20.941 INFO 7868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2021-09-07 21:28:20.967 INFO 7868 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 6.044 seconds (JVM running for 7.015)
远程debug客户端启动后,debug连接建立
本地打断点,发送请求:192.168.57.120:8080/hello
listen模式重新debug,需要重启远程应用,attach模式不需要
-
Springboot-如何开启debug日志?
2021-12-22 19:44:50如何开启? 在配置文件,配置debug=true。 输入的时候,会有智能提示。 启动成功,打印debug日志 其实就是打印了debug日志,然后具体多了什么日志信息呢? springboot自动配置有哪些? 有哪些servlet请求... -
springboot-如何开启debug日志?
2021-12-20 21:54:32如何开启? 在配置文件,配置debug=true。 输入的时候,会有智能提示。 启动成功,打印debug日志 其实就是打印了debug日志,然后具体多了什么日志信息呢? springboot自动配置有哪些? 有哪些servlet请求... -
springboot项目debug启动慢
2021-07-21 13:51:06开启了方法断点,启动时idea会有提示Method breakpoints may dramatically slow down debugging,意思就是在方法上打了断点会导致启动很戏剧性的变慢。 解决方法 去掉方法断点,就是菱形标记的那种断点 ... -
SpringBoot系列:开启远程Debug
2022-04-08 14:09:541、linux服务器启动springboot 项目jar包时使用如下...address=18888为debug模式监听端口 -Xmx2048M 视实际情况配置 xxx.jar 业务jar包名称; 2、ecplise下监听端口: 进入Ecplise – > Run – > Debug Configura -
springboot idea debug 模式下启动特别忙,且无法访问
2018-03-20 15:27:001、找一下java Method breakpoints的问题,要去掉这样的断点,就是四个点的。 转载于:https://www.cnblogs.com/wu-fm/p/8609538.html -
springboot debug模式启动会有断点,springboot debug启动不进入断点
2021-04-02 15:31:16springboot debug模式启动会有断点,springboot debug启动不进入断点 ================================ ©Copyright 蕃薯耀2021-03-30 https://www.cnblogs.com/fanshuyao/ ================================ ©... -
idea中springboot怎么开启debug调试
2018-07-23 16:10:38网上有好多关于怎么启动springboot的debug调试的,在pom中添加属性,然后等等等等,特别麻烦。 1、打开Run/Debug Configurations, 2、选择Spring Boot 下要进行debug调试的服务, 3、在VM options:的填写框中... -
springboot开启debug日志_Spring Boot SLF4J日志实例(五十)
2020-12-01 13:23:38注意:查看此Spring Boot Logback XML模板以了解默认的日志记录模式和配置。SLF4j示例我们将在接下来的文章中,创建一个项目:web-slf4j-logging,演示这几种常用的日志配置方法。1. application.properties要启用... -
SpringBoot项目远程Debug
2021-07-31 22:25:33SpringBoot项目远程Debug 1.在远程服务器上使用java -jar启动jar包时,加上参数-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 如: java -jar -Xdebug -Xrunjdwp:transport=dt_socket,... -
SpringBoot远程Debug
2021-06-29 16:47:42SpringBoot项目远程DEBUG 参考博客CSDN链接 1.Idea构建SpringBoot测试Demo pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns=... -
SpringBoot启动debug级别日志报错Tomcat Native library could not be found using names [tcnative-1, ...
2022-04-06 23:11:37SpringBoot启动debug级别日志报错Tomcat Native library could not be found using names [tcnative-1, libtcnative-1] 错误截图 原因 tomcat没有找到JNI动态链接库。Apache Tomcat下是有这个dll的,但是启动时在... -
IDEA中SpringBoot远程debug
2021-05-09 19:44:22目录SpringBoot远程debug一、本地配置内容二、服务器启动三、本地启动四、测试五、结束 SpringBoot远程debug 大家是否经常遇到这种情况,项目在本地运行得好好得,但是一上到服务器就拉胯,以前我的应对方法就是加上... -
springboot在debug模式下启动超时的解决办法
2020-03-17 00:12:43打好断点之后debug模式启动,过去10分钟迟迟没有启动成功 经过百度: eclipse和tomcat 启动之后 读取文件失败,or,eclipse自动设置断点(或者以前打的断点没取消影响了启动) 解决办法: 在debug页面 ,右上角的... -
关掉SpringBoot中的debug日志
2021-01-27 21:40:51在Resources目录下添加文件logback.xml,重启SpringBoot <?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/base.xml" /> ... -
开启springboot工程下spring的全局debug模式
2019-12-01 18:24:18application.properties加入如下配置 logging.level.org.springframework= debug 如图所示 -
SpringBoot项目配置远程Debug
2021-02-23 02:05:54一、IDEA配置 二、服务器启动命令 java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8900 remote-0.0.1-SNAPSHOT.jar 这里在... 三、访问远程服务地址 IDEA中启动remote,只有debug模式 -
SpringBoot在properties文件和yml文件中设置debug打印
2022-02-07 20:56:35在properties文件中,我们为项目的运行结果设置为debug打印是这样的 logging.level.包名.debug(包名例com.baidu.dao),注意...以上就是关于在properties文件和yml文件中,SpringBoot项目配置为debug打印的介绍。 ... -
SpringBoot 远程DeBug
2019-06-16 22:54:58远程debug调试java代码 日常环境和预发环境遇到问题时,可以用远程调试的方法本地打断点,在本地调试。生产环境由于网络隔离和系统稳定性考虑,不能进行远程代码调试。也就是说,你本地运行没问题啊,为啥放服务器上... -
Springboot jar包启动远程debug
2021-02-25 19:36:55-spring.profiles.active=pro 其中–spring.profiles.active=pro 含义为指定以pro配置文件启动服务 在IDEA配置中配置 Name:自定义名称 Host:远程连接的服务器ip Port:刚才启动的接口(8000) 选择刚才配置的 debug即可 -
SpringBoot在IDEA中的几种debug方式
2019-10-09 14:24:02IDEA中支持debug几种方式介绍Java -jar 命令启动项目debug使用Docker容器部署项目debug注意事项 介绍 项目开发中不管是在本地,测试,生成环境中都避免不了bug的产生,有些比较棘手的问题还需要追踪代码才能一目了然... -
springboot中 开启MongoTemplate的DEBUG模式
2021-11-04 14:45:59logging: level: org.springframework.data.mongodb.core.MongoTemplate: DEBUG -
SpringBoot程序远程debug
2019-12-16 15:04:09所谓的远程调试就是服务端程序运行在一台远程服务器上,我们可以在...下面介绍一下Intellij IDEA下对Springboot类型的项目的远程调试功能。 首先,打开Edit configurations,点击+号,创建一个Remote应用。 ... -
IDEA启动Springboot项目,使用release模式(即run方式)正常,debug模式卡住
2021-12-15 15:06:37但是,使用debug模式启动的时候,启动到一半就会卡住不动。期间我改过yml配置,还以为是配置不成功呢,但是run方式启动成功,让我打消了念头 解决方式: 将所有“断点”去除掉,重新启动,即可。 感谢这个兄弟提供...