eclipse 调试显示行号错误的源文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16470244/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
eclipse debugging shows source files with wrong line numbers
提问by teddy teddy
when I click F3 and drill down into a method definition, eclipse goes into a dependency jar. ----- first question: where did it get the source file? I don't see the jars containing actual source files, did it decompile ? ---- I set a breakpoint, and run debug.
当我单击 F3 并深入查看方法定义时,eclipse 进入依赖项 jar。----- 第一个问题:它的源文件是从哪里得到的?我没有看到包含实际源文件的 jars,它反编译了吗?---- 我设置了一个断点,然后运行调试。
but the debugging process never seems to land on the correct breakpoint, and the breakpoint I set is rarely executed. it turns out that the source code shown is wrong, so that the breakpoint is set at wrong locations too.
但是调试过程似乎永远不会落在正确的断点上,而且我设置的断点很少被执行。事实证明,显示的源代码是错误的,因此断点也设置在错误的位置。
here is what I see from eclipse window:
这是我从 eclipse 窗口看到的:
/* */ public <T> T execute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor)
/* */ throws RestClientException
/* */ {
/* 415 */ return doExecute(url, method, requestCallback, responseExtractor);
/* */ }`
the comment before each line seems to show the correct line number, but they do not match up with their true line number shown on the left of the eclipse window frame. i.e. the above code segment occupies lines 315--319 in the window, not 415.
每行之前的注释似乎显示了正确的行号,但它们与 eclipse 窗口框架左侧显示的真实行号不匹配。即上面的代码段在窗口中占据了315--319行,而不是415行。
so how can I grab the correct sources and display them in my debugging process? do I have to manually grab all the jars ? is there a way to specify in my pom file?
那么如何获取正确的源并在调试过程中显示它们呢?我必须手动抓取所有罐子吗?有没有办法在我的 pom 文件中指定?
thanks Yang
谢谢杨
回答by Fernando Paz
Because I didn't find the solution when I googled it and this is the first search result, I want to share how I solved this issue.
因为我在google上没有找到解决方案,这是第一个搜索结果,我想分享一下我是如何解决这个问题的。
- In Eclipse, ensure that
Project > Build Automatically
is checked; - Right click in your project and go
to Build Path > Configure Build Path...
- Check the tabs for errors (missing dependencies, sources not found, etc), fix/delete them and press OK.
- In Eclipse, go to
Project > Clean...
, select your project and press OK;
- 在 Eclipse 中,确保
Project > Build Automatically
已选中; - 右键单击您的项目并转到
to Build Path > Configure Build Path...
- 检查选项卡是否有错误(缺少依赖项、未找到源等),修复/删除它们,然后按 OK。
- 在 Eclipse 中,转到
Project > Clean...
,选择您的项目并按 OK;
If you get errors at step #3 (like Access denied or similar), go to the root folder of your project and look for a file called .classpath
. Edit the file and manually fix/remove the block that is causing the error.
如果您在第 3 步遇到错误(如拒绝访问或类似),请转到项目的根文件夹并查找名为.classpath
. 编辑文件并手动修复/删除导致错误的块。
This also solves when Eclipse doesn't display error icons in classes with compilation errors.
这也解决了 Eclipse 在编译错误的类中不显示错误图标的问题。
回答by klib009
In Eclipse, you can specify the sources for debugging under Run -> Debug Configurations. Select your Debug configuration from the list and configure the Source lookup path in the 'Source' tab
在 Eclipse 中,您可以在 Run -> Debug Configurations 下指定用于调试的源。从列表中选择您的调试配置并在“源”选项卡中配置源查找路径
回答by theFrok
I had this issue and it happed because I had multiple version of the same dependency in my .m2
. So I solved it by deleting unnecessary versions.
我遇到了这个问题并且它发生了,因为我的.m2
. 所以我通过删除不必要的版本来解决它。
default location would be -
C:\Users\[username]\.m2\repository
默认位置是 -
C:\Users\[username]\.m2\repository