如何强制 IntelliJ 只进入我的源代码?

我有一个 Spring MVC 项目,我正在尝试使用 IntelliJ 进行调试。

如果在 Controller 代码中设置了断点,调试将在适当的位置停止。这一行在另一个 bean 中有更多我自己的代码。我希望能进入密码。如果我在断点操作工之后立即“进入”,那么它将进入 Spring 的 AOP 框架代码。

enter image description here

如果我立即触发相同的断点和“智能步入”,它会将我置于源文件的第 -1行(在上面的图中很明显)。这行 -1代表什么?如果我再次执行“智能步入”操作,那么我最终会到达原始断点之后的行,但是从未被放置到我想要步入的方法中。

我已经尝试将 SpringAOP 包放入调试器设置 不要进入课堂中。然而,我最终还是不得不放入事务类以及其他几个类。最后,我把所有的 Spring 放进了列表中... 还有 SLF4J 和一些 JDBC 驱动程序。

如何才能让 IntelliJ 只停留在我的项目源代码中,除非我使用“强制进入”之类的东西?

25894 次浏览

Currently there is no overall option to only target user code (like Visual Studio's 'Just My Code').

The best way to have the same behavior is to exclude specific code classes or packages (it is possible to setup filter patterns for class packages via wildcards) that will not be 'stepped into'.

This can be achieved within the Settings/Preferences, in the Debugger/Stepping options.

Spring's AOP may be among the worst offenders.

The OP suggested that they had already done this, but here's how you can disable stepping into specified classes (IntelliJ ULTIMATE 2018.2):

File -> Settings... -> Build, Execution, Deployment -> Debugger -> Stepping

... Do not step into the classes -> Add Pattern -> Enter the filter pattern:

... ... org.springframework.aop.*

Notice that you can use wildcards to disable entire namespaces -- so for example, assuming that your organization's namespace starts with com, you can get most of the way there by blacklisting org.*.

IntelliJ ULTIMATE 2018.3 Using File -> Settings -> search 'Step' as follow: enter image description here

Another way in "Ultimate 2019.1" (may be also in previous versions):

When you're right now debugging you can make a right mouse click on a class in the view "Debugger" - "Frames". Then you can select "Add stepping filter..." and adding for that class a new step filter. Of course you can here also change the new step filter, using place holder "*" and so on ...

After the changes mentioned above, stop your application and restart into debug mode again to take effect.