欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring Boot Debug調(diào)試過程圖解

 更新時間:2020年01月08日 14:29:55   作者:Java技術(shù)棧  
這篇文章主要介紹了Spring Boot Debug調(diào)試過程圖解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

這篇文章主要介紹了Spring Boot Debug調(diào)試過程圖解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

最近發(fā)現(xiàn) Spring Boot 本地不能 Debug 調(diào)試了,原來 Spring Boot 升級后,對應(yīng)插件的命令參數(shù)都變了,故本文做一個升級。

背景:

Spring Boot 項(xiàng)目在使用 Spring Boot Maven 插件執(zhí)行啟動命令 spring-boot:run 的時候,如果設(shè)置的斷點(diǎn)進(jìn)不去,要進(jìn)行以下的設(shè)置。

官方解決方案:

By default, the run goal runs your application in a forked process. If you need to debug it, you should add the necessary JVM arguments to enable remote debugging. The following configuration suspend the process until a debugger has joined on port 5005:

直接看怎么做吧!

1、添加 JVM 參數(shù)

在插件 spring-boot-maven-plugin 里面加上 jvmArguments 配置。

<project>
 ...
 <build>
  ...
  <plugins>
   ...
   <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.2.0.RELEASE</version>
    <configuration>
     <jvmArguments>
      -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
     </jvmArguments>
    </configuration>
    ...
   </plugin>
   ...
  </plugins>
  ...
 </build>
 ...
</project>

或者在命令行指定:

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

最新配置可以參考官方說明:

https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html

2、添加一個Remote

在開發(fā)工具里面新增一個 Remote 配置:

只需要確定 Host、Port 參數(shù)即可。

Host:地址

localhost:本地啟動地址;

Port:端口

5005:上面命令行指定的端口;

3、開始調(diào)試

先啟動加了 jvmArguments 參數(shù)的 Spring Boot 項(xiàng)目:

程序停在監(jiān)聽端口:5005,再 debug 啟動Remote:

再回到項(xiàng)目,開始啟動輸出日志,然后就可以進(jìn)行斷點(diǎn)調(diào)試了。

這就是遠(yuǎn)程調(diào)試了,也能幫你 debug 遠(yuǎn)程 Spring Boot 應(yīng)用,但在本地調(diào)試要操作兩次,略顯麻煩。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論