简体   繁体   English

在Eclipse中,如何在调试时附加不同的源文件

[英]In Eclipse, how to attach different source files when debugging

While debugging our web app, we needed to trace thru the code, including 3rd party open source software. 在调试我们的Web应用程序时,我们需要通过代码进行跟踪,包括第三方开放源代码软件。

When looking at this problem with several people on my laptop, someone quickly downloaded the latest source jar file and pointed our project to that jar file. 当我的笔记本电脑上有几个人看着这个问题时,有人迅速下载了最新的源jar文件并将我们的项目指向该jar文件。 However, since it's not the same version, the lines of code don't match so when debugging, it can point to blank lines. 但是,由于版本不同,因此代码行不匹配,因此在调试时,它可以指向空行。

Afterwards, I found the correct git branch, and downloaded the correct version of code, or at least it's closer to the code we're using than the code someone else downloaded. 之后,我找到了正确的git分支,并下载了正确的代码版本,或者至少它比其他人下载的代码更接近我们正在使用的代码。 However, it seems like Eclipse is still using the old code. 但是,似乎Eclipse仍在使用旧代码。 In Eclipse, I went into Projects->Properties->Java Build Path->Libraries and deleted the jar file that I think contains the code but it still seems to be using the old code. 在Eclipse中,我进入了Projects-> Properties-> Java Build Path-> Libraries,并删除了我认为包含代码的jar文件,但它似乎仍在使用旧代码。

When I continue debugging after deleting this file, it doesn't give me the choice to Attach Source. 删除此文件后继续调试时,它没有给我附加源的选择。 How do I make Eclipse allow me to use another source file when tracing thru code when debugging? 在调试时通过代码跟踪时,如何使Eclipse允许我使用另一个源文件?

If deleting the jar file should have fixed this problem, then I probably deleted the wrong jar file and will delete this question since it's user error. 如果删除jar文件应该可以解决此问题,那么我可能删除了错误的jar文件,并且由于用户错误,将删除此问题。

In the Debug view, select the Debug tab. 在“调试”视图中,选择“调试”选项卡。 Right click your debug instance and choose "Edit source lookup..." 右键单击您的调试实例,然后选择“编辑源代码查找...”

See below: 见下文:

在此处输入图片说明

Be sure to run a Project Clean after changing the source lookup. 更改源查找后,请确保运行Project Clean。 I have run into many inconsistencies in various versions of Eclipse with this feature. 在具有此功能的各种版本的Eclipse中,我遇到了许多不一致之处。

If you are using maven you can instruct maven to automatically download the source jars. 如果您正在使用Maven,则可以指示Maven自动下载源jar。 This should usually be the right version. 通常这应该是正确的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM