调试 IntelliJ 中的 Spring 依赖

huangapple go评论77阅读模式
英文:

Debugging spring dependency in IntelliJ

问题

我正在为一个Spring应用程序创建一个模块。它的工作方式是,主应用程序包括模块,并在运行时捕获其Spring注解。因此,在IntelliJ的两个不同窗口中最终会有两个不同的项目。

所以,要运行我的模块,我必须在本地仓库中进行mvn install,然后运行包含它在<dependencies>中的应用程序。

我在IntelliJ中同时打开了这两个项目。我在模块中设置了一个断点,然后运行主应用程序,并调用模块中定义的端点。它并没有停下来,这正是我预期的。是否有一种类似的方式来调试我的模块?由于涉及数据库和配置,我需要外部应用程序,因此无法直接运行该模块。

英文:

I'm creating a module for a Spring application. The way it works is that the main application includes modules and when it runs it picks up on its Spring annotations. So it ends up being two different projects on two different windows in IntelliJ.

So to run my module, I have to mvn install it in the local repository and then it run the application which includes it in the &lt;dependencies&gt;.

I have both projects open in IntelliJ. I set a breakpoint in the module, run the main application, and call the endpoint defined in the module. It doesn't stop, which I expected. Is there a way to do something equivalent to debug my module? I need the outside application because of the database and configurations, so I can't run the module directly.

答案1

得分: 1

假设有两个模块A和B,其中B模块作为A模块的依赖添加。如果你想要从A模块调试代码流程到B模块,与其在B项目中(在IntelliJ中导入)设置断点,你应该只在模块A中设置断点。

你必须知道模块B中类的包名,这样你可以从外部库中导航到该类,并在模块B的类中所需的方法上设置断点。

打开项目A内部的项目B的依赖类,并附加断点。

以调试模式运行应用程序A,最终会触发B项目中的依赖部分。

调试 IntelliJ 中的 Spring 依赖

英文:

Let's suppose there are 2 modules A and B where B module is added as dependency in module A. If you want to debug the code flow from A to B, instead of putting breakpoint in B project (imported in IntelliJ) you have to put breakpoint in module A only.

调试 IntelliJ 中的 Spring 依赖

You must be aware of package of the class in module B, so you can navigate to that class from external libraries and put breakpoint on required method of class in module B.

Open the depedency class of project B inside A and attach the breakpoints.

Run application A with debug mode on, your depedency in B project will get hit eventually.

huangapple
  • 本文由 发表于 2020年8月18日 22:49:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63471193.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定