Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码

时间:2021-10-10 20:19:35

I set a breakpoint in my .java file. I started jetty via maven-jetty plugin. The java file where I set the breakpoint is also packaged into a JAR. Intellij stops at the breakpoint, but it shows me the file which is packaged into the JAR instead of the java file. It behaves as if I set a breakpoint in a java file of 3rd party libraries source code. How can I either make Intellij ignore my JAR or force Intellij to stop at my .java file?

我在.java文件中设置了一个断点。我通过maven-jetty插件启动了jetty。我设置断点的java文件也打包到JAR中。 Intellij在断点处停止,但它显示了打包到JAR而不是java文件的文件。它表现得好像我在第三方库源代码的java文件中设置断点。如何让Intellij忽略我的JAR或强制Intellij停在我的.java文件中?

2 个解决方案

#1


3  

The setup for this is two fold.

这个设置是双重的。

  1. Add the source to one of your modules' classpath. (Project Structure -> Dependencies -> Add -> Module Dependency -> Pick your source and drag it above all library dependencies) Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码
  2. 将源添加到模块的一个类路径中。 (项目结构 - >依赖项 - >添加 - >模块依赖项 - >选择源并将其拖到所有库依赖项之上)
  3. Point your Remote Configuration to search for the sources in that particular module's classpath. See picture below Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码
  4. 指向远程配置以搜索该特定模块的类路径中的源。见下图

There is an option to search "whole project" for sources, but this did not set precedence to locally available sources, over downloaded sources, when I attempted to use it. The above solution fixed this problem for me, but it is relatively unsatisfactory when working with a large multiple project setup. i.e I had to pick one particular module's classpath as the source of truth in Remote Configurations. In my opinion, if the local source is present, and "whole project" is the search option, IntelliJ should be smart enough to choose local source over libaries

有一个选项可以搜索“整个项目”的来源,但是当我尝试使用它时,这并未设置优先于本地可用的源,而不是已下载的源。上面的解决方案为我解决了这个问题,但是在处理大型多项目设置时相对不令人满意。即我必须选择一个特定模块的类路径作为远程配置中的真实来源。在我看来,如果本地源存在,并且“整个项目”是搜索选项,IntelliJ应该足够聪明,可以选择本地源而不是库

#2


0  

In the current latest version of IntelliJ IDEA (2018.1) there is an option "Show alternative source switcher":

在当前最新版本的IntelliJ IDEA(2018.1)中,有一个选项“显示替代源切换器”:

Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码

After enabling this option IDEA detects discrepancy of *.java and *.class files and offers to choose source of sources (sorry about tautology). It can ease pain of debugging in projects that consist of many modules.

启用此选项后,IDEA会检测* .java和* .class文件的差异,并提供选择源的来源(对不起重言式)。它可以减轻由许多模块组成的项目中的调试痛苦。

#1


3  

The setup for this is two fold.

这个设置是双重的。

  1. Add the source to one of your modules' classpath. (Project Structure -> Dependencies -> Add -> Module Dependency -> Pick your source and drag it above all library dependencies) Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码
  2. 将源添加到模块的一个类路径中。 (项目结构 - >依赖项 - >添加 - >模块依赖项 - >选择源并将其拖到所有库依赖项之上)
  3. Point your Remote Configuration to search for the sources in that particular module's classpath. See picture below Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码
  4. 指向远程配置以搜索该特定模块的类路径中的源。见下图

There is an option to search "whole project" for sources, but this did not set precedence to locally available sources, over downloaded sources, when I attempted to use it. The above solution fixed this problem for me, but it is relatively unsatisfactory when working with a large multiple project setup. i.e I had to pick one particular module's classpath as the source of truth in Remote Configurations. In my opinion, if the local source is present, and "whole project" is the search option, IntelliJ should be smart enough to choose local source over libaries

有一个选项可以搜索“整个项目”的来源,但是当我尝试使用它时,这并未设置优先于本地可用的源,而不是已下载的源。上面的解决方案为我解决了这个问题,但是在处理大型多项目设置时相对不令人满意。即我必须选择一个特定模块的类路径作为远程配置中的真实来源。在我看来,如果本地源存在,并且“整个项目”是搜索选项,IntelliJ应该足够聪明,可以选择本地源而不是库

#2


0  

In the current latest version of IntelliJ IDEA (2018.1) there is an option "Show alternative source switcher":

在当前最新版本的IntelliJ IDEA(2018.1)中,有一个选项“显示替代源切换器”:

Intellij IDEA Breakpoints在JAR中停止,而不是我的项目的源代码

After enabling this option IDEA detects discrepancy of *.java and *.class files and offers to choose source of sources (sorry about tautology). It can ease pain of debugging in projects that consist of many modules.

启用此选项后,IDEA会检测* .java和* .class文件的差异,并提供选择源的来源(对不起重言式)。它可以减轻由许多模块组成的项目中的调试痛苦。