Eclipse java调试:找不到源代码 [英] Eclipse java debugging: source not found

查看:32
本文介绍了Eclipse java调试:找不到源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Eclipse 中调试 Java 应用程序时,我在两种情况下收到找不到源"错误:

While debugging a java app in eclipse I receive a "Source not found" error in two cases:

  • 进入已导入的不同项目中的文件
  • 进入已安装的 Maven 存储库中的文件

文件在那里,但eclipse不会进入它们,而是显示一个按钮附加源"

The files are there, but eclipse won't step into them, instead it shows a button to "attach source"

我尝试附加(它打开了一个对话框来定义一个变量?!)并且 eclipse 确实跳转到了该文件,但是调试器无法检查那里的任何变量.此外,手动附加每个依赖项的源代码也不切实际,因为在我的情况下有数千个依赖项文件.

I tried attaching (which opened a dialog to define a variable?!) and eclipse did jump to the file, but the debugger could not inspect any variables there. Also manually attaching the source for each dependency isn't practical, as in my case there are thousands of dependency files.

我是 eclipsejava 的新手,所以解释为什么会发生这种情况 + 如何解决这个问题会很有帮助!

I'm new to eclipsejava so an explanation of why this is happening + how to resolve this would help a lot!

推荐答案

Eclipse 调试与程序实际加载的类一起工作.

Eclipse debugging works with the class actually loaded by the program.

您描述的症状听起来像是在项目中找不到相关类,但在您正在使用的项目之前找到了没有调试信息的分发 jar.

The symptoms you describe sounds like the class in question was not found in the project, but in a distribution jar without debug info found before the project you are working with.

发生这种情况的原因有多种,但请查看显示此行为的类所在的位置(查看导航窗格以识别它).您很可能需要更改项目的构建路径以避免使用此 jar 并让 JVM 使用该项目.

This can happen for several reasons but have a look at the location where the classes showing this behaviour is found (look in the navigation pane to identify it). You will most likely need to change the build path of the project to avoid using this jar and have the JVM use the project instead.

请注意,从 2018 年开始,使用像 Maven 这样的构建框架是很常见的,其中构建路径由 m2e 插件管理,因此这个问题应该比提出问题时出现的频率低得多.如果您使用 Maven 和 m2e,请确保启用 Preferences/Maven/Download Artifact Sources" 或右键单击项目,Maven/Download Sources".

Note that as of 2018 it is common to use a build framework like Maven, where the build path is managed by the m2e plugin so this problem should be very less frequent than when the question was asked. If you use Maven and m2e, make sure to enable Preferences / Maven / "Download Artifact Sources" or right-click the project, Maven / "Download Sources".

这篇关于Eclipse java调试:找不到源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆