Eclipse 调试器运行错误版本的代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8695070/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:31:22  来源:igfitidea点击:

Eclipse debugger runs wrong version of code

eclipse

提问by intA

I copied an Eclipse Java project and tried to run the debugger on the copied version. The debugger used the code of the old project. What can I do in this situation?

我复制了一个 Eclipse Java 项目并尝试在复制的版本上运行调试器。调试器使用了旧项目的代码。在这种情况下我能做什么?

回答by Francis Upton IV

Have a look at the launch configuration that you are using to start the debugger. In the Package/Project explorer, do right-click Debug As..and then select Debug Configurationsand make sure all of the details of the launch configuration you are using line up with your new project.

查看用于启动调试器的启动配置。在包/项目资源管理器中,右键单击Debug As..并选择Debug Configurations并确保您正在使用的启动配置的所有详细信息与新项目保持一致。

回答by Luke Hutchison

Right-click on the top frame in the debugger's stack view, and select "Edit source lookup...". Remove the incorrect source entry from the list, and/or add the correct one.

右键单击调试器堆栈视图中的顶部框架,然后选择“编辑源查找...”。从列表中删除不正确的源条目,和/或添加正确的条目。

回答by iamcoming

in my case, I have 2 project (A and B) that is referring different version of C. Say A is referring C version 1, and B is referring C version 2. When I am debugging A, C version 2 's source came up always, not C version 1. I ends up adjust the order in debug configuration by remove project B and re-add it. I made project A ahead of project B. That solves the problem.

就我而言,我有 2 个项目(A 和 B)指的是 C 的不同版本。假设 A 指的是 C 版本 1,B 指的是 C 版本 2。当我调试 A 时,C 版本 2 的源代码来了总是向上,而不是 C 版本 1。我最终通过删除项目 B 并重新添加它来调整调试配置中的顺序。我在项目 B 之前做了项目 A。这解决了问题。

回答by mor222

One thing you can do is to link your server project src folder to your current project.

您可以做的一件事是将您的服务器项目 src 文件夹链接到您当前的项目。

This could be done as follows:

这可以按如下方式完成:

Right click on project B --> Properties --> Java Build Path --> Source --> Link Source --> Browse, then locate the A project src. Finally change the Folder name field as you wish.

右键单击项目 B --> Properties --> Java Build Path --> Source --> Link Source --> Browse,然后找到 A 项目的 src。最后根据需要更改文件夹名称字段。

I hope this helps :)

我希望这有帮助 :)

回答by Bandjalong

I had the same problem. Going into the Debug Configurations as per Francis Upton's answer it all looked fine, but I still had the same problem.

我有同样的问题。按照 Francis Upton 的回答进入调试配置,一切看起来都很好,但我仍然遇到同样的问题。

Restarting Eclipse fixed it.

重新启动 Eclipse 修复了它。