Intellij IDEA Breakpoints stop in JARs instead of source code of my project

≡放荡痞女 提交于 2019-12-23 12:48:02

问题


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?


回答1:


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)

  2. Point your Remote Configuration to search for the sources in that particular module's classpath. See picture below

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




回答2:


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

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.



来源:https://stackoverflow.com/questions/18992181/intellij-idea-breakpoints-stop-in-jars-instead-of-source-code-of-my-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!