右键运行
@SpringBootApplication
public class MyApplication {
public static void main(String[] args){
//打印类加载器
System.out.println(MyApplication.class.getClassLoader());
SpringApplication.run(MyApplication.class, args);
}
}
运行
"C:\Program Files\Java\jdk1.8.0_192\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:D:\ideaIU-2019.3.3.win\lib\idea_rt.jar=54322:D:\ideaIU-2019.3.3.win\bin -Dfile.encoding=GBK -classpath "C:\Program Files\Java\jdk1.8.0_192\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_192\jre\lib\deploy.jar;C:\Program 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
api\2.12.1\a55e6d987f50a515c9260b0451b4fa217dc539cb\log4j-api-2.12.1.jar" com.shengsiyuan.boot.MyApplication
sun.misc.Launcher$AppClassLoader@18b4aac2
//打成Jar包
E:\spring_lecture>gradle bootJar
打包之后运行输出
java -jar spring_lecture-1.0.jar
org.springframework.boot.loader.LaunchedURLClassLoad@439f5b3d
看出相同代码,不同启动方式,加载的类不一样
远程调试JDWP(Java Debug Wire Protocol,java调试协议)
Java提供了一种关于调试的协议JDWP,程序在服务器上运行,运行的程序关联的代码断点还在本机停留在本机的电脑
C:\Users\Administrator>java -agentlib:jdwp=help
Java Debugger JDWP Agent Library
--------------------------------
(see http://java.sun.com/products/jpda for more information)
jdwp usage: java -agentlib:jdwp=[help]|[<option>=<value>, ...]
Option Name and Value Description Default
--------------------- ----------- -------
suspend=y|n wait on startup? y 程序已启动就停止
transport=<name> transport spec none
address=<listen/attach address> transport spec "" 地址,端口号
server=y|n listen for debugger? n //是否监听调试器,设置为Y
launch=<command line> run debugger on event none //时间发生时候设置调试器
onthrow=<exception name> debug on throw none //抛出异常的时候就会执行异常处理中
onuncaught=y|n debug on any uncaught? n
timeout=<timeout value> for listen/attach in milliseconds n
mutf8=y|n output modified utf-8 n
quiet=y|n
主要用前面四个
C:\Users\Administrator>
打断点,在IDEA
External Libraries ->spring-boot-loader-2.1.3.RELEASE.jar->org.springframework.boot.loader->JarLauncher
51行new JarLauncher().launch(args);
1调试命令,服务器上启动
C:\Users\Administrator>java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5050 -jar spring-lecture-0.0.1-SNAPSHOT.jar
Listening for transport dt_socket at address: 5050
2在IDEA中设置往5050端口发送消息
Run/Debug Configurations中进行设置
+ 号-> 查找到远程Remote
Name : myDebug
Configuration->Debugger mode ->Attach to remote JVM
Host:localhost //远程主机IP
Port:5050
Use module classpath:com.shengsiyuan.spring_lecture或者spring_lecture
之后确定应用,点击IDEA软件右上角的蜘蛛调试按钮
字后代码会停在如下地方
main:52, JarLauncher (org.springframework.boot.loader)
之后按键盘F7,会跟进到,一直按F7,之后调试随个人知识积累
public JarLauncher(){
}
10打包以及远程调试(JDWP)
最新推荐文章于 2024-04-08 21:22:37 发布