Rui*_*uik 5 debugging intellij-idea spring-boot
由于迁移到 Spring Boot 3,当我运行 Maven Spring Boot goal 时,我的应用程序不再停留在断点处mvn spring-boot:run。
这是因为 Spring 分叉了线程或进程,并且调试器未附加到此。
在以前的 Spring-Boot 版本中,您可以通过传递来禁用分叉-Dspring-boot.run.fork=false(请参阅如何使用 IntelliJ IDEA 社区版调试 spring-boot 应用程序?)。
不幸的是,这个选项已被删除,您可以在Spring Boot 3.0 迁移指南中阅读:
Spring Boot 2.7 中已弃用的 spring-boot:run 和 spring-boot:start 的 fork 属性已被删除。
有没有可能让断点再次起作用?
当然IntelliJ Ultimate有更好的Spring Boot集成。我正在尝试使其与社区版一起使用。
我还尝试不运行 Maven 目标,而是进行应用程序运行配置。到目前为止,这失败了,因为java.lang.ClassNotFoundException它找不到 Main 类。不确定我是否应该进一步调查该选项。
最后一个想法是使用调试选项启动 Maven 目标,以便可以附加外部调试器。这也不起作用,即使可以,我也只能在启动后附加调试器,这将使调试 spring 上下文的创建变得不可能。
选项 3似乎有效,在单独的终端中启动 Maven 目标。
pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
终端:
PS> mvn spring-boot:run -f .\pom.xml
# ...
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005
Run Code Online (Sandbox Code Playgroud)
IntelliJ IDEA:
5005)| 归档时间: |
|
| 查看次数: |
1661 次 |
| 最近记录: |