在Eclipse中调试我的Java代码时,我得到“Source not found”

时间:2022-02-06 23:55:05

I'm trying to debug my Java application in Eclipse however when I hit a breakpoint I simply see the following instead of my source:

我正在尝试在Eclipse中调试我的Java应用程序,但是当我遇到断点时,我只是看到以下内容而不是我的源代码:

在Eclipse中调试我的Java代码时,我得到“Source not found”

If I change the stack frame in the Debug window then I can see the function name change in the tab - this is definitely my code, the line number is correct and I'm using the latest build but I still can't get Eclipse to show the source (despite it being open in another tab!)

如果我在调试窗口中更改堆栈帧,那么我可以看到选项卡中的函数名称更改 - 这绝对是我的代码,行号是正确的,我使用的是最新版本,但我仍然无法将Eclipse转换为显示源(尽管它在另一个选项卡中打开!)

I'm new to Eclipse and so I'm struggling to find my way around, but everything that I've stumbled across so far seems fine to me.

我是Eclipse的新手,所以我很难找到自己的方式,但到目前为止我遇到的所有事情对我来说都很好。

What might cause this to happen and how can I fix it?

可能导致这种情况发生的原因以及如何解决?

14 个解决方案

#1


21  

Sounds like the 'source lookup path' section if you edit the debug configuration isn't setup correctly?

如果编辑调试配置未正确设置,听起来像'源查找路径'部分?

#2


11  

Click on "Edit Source Lookup Path" button and then click on Add button then Java Project and include your imported project .. Hope this will solve your problem

单击“编辑源查找路径”按钮,然后单击“添加”按钮,然后单击“Java项目”并包含导入的项目..希望这将解决您的问题

#3


4  

I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild projet with

我的eclipse maven项目遇到了类似的问题。我和这个问题打了很长时间,然后我试着重建projet

mvn clean eclipse:eclipse

and it helped.

它帮助了。

#4


3  

I also had this issue in MyEclipse Blue. I resolved this one by following these steps:

我在MyEclipse Blue中也有这个问题。我按照以下步骤解决了这个问题:

  1. Debug the project.

    调试项目。

  2. Right click on the Thread (Which you will see in Debug tab) and click on the "Edit Source lookup"

    右键单击Thread(您将在Debug选项卡中看到),然后单击“Edit Source lookup”

  3. New window will open and hit the "Add" button and Select the "Java Project".

    将打开新窗口并单击“添加”按钮并选择“Java项目”。

  4. Get all the project that is listed over there.

    获取那里列出的所有项目。

  5. Restart your server.

    重启你的服务器。

#5


1  

We had the same problem and none of the suggestions above worked. What did work, was deleting the local workspace and from Eclipse checking out from the repository again. The problem occured for everybody previously working with Netbeans and making the switch to Eclipse.

我们遇到了同样的问题,上述建议都没有奏效。什么工作,是删除本地工作区和Eclipse再次从存储库中检出。以前使用Netbeans并切换到Eclipse的每个人都遇到了这个问题。

#6


1  

For local projects I've solved it by selecting the "Resolve Workspace artifacts" checkbox in the Debug Configurations.

对于本地项目,我通过选择Debug Configurations中的“Resolve Workspace artifacts”复选框来解决它。

#7


1  

When I faced this problem for the very first time, I've already done all the steps mentioned here. Curiously, my problem happened when I've copied a project into another place. Anyway, the debug starts to work without warnings, after simply remove all breakpoints that was originated from the original project. Sorry about my English , I'm not fluent.

当我第一次遇到这个问题时,我已经完成了这里提到的所有步骤。奇怪的是,当我将项目复制到另一个地方时,我的问题就发生了。无论如何,在简单地删除源自原始项目的所有断点之后,调试开始工作而没有警告。抱歉我的英语,我不会流利。

#8


1  

Try this:

  • Select Project
  • Right click
  • debug
  • Debug configuration
  • Select Source Tab
  • 选择Source选项卡

  • Click on add button
  • 单击“添加”按钮

  • Select Java Project
  • 选择Java Project

  • Add your project there with check box
  • 使用复选框添加项目

#9


1  

After trying most of the solutions here, try this too once -

在尝试了大多数解决方案后,尝试一次 -

Close all the .java files from the editor, in fact, close all unrelated projects in eclipse. And try running the Debugger.

从编辑器中关闭所有.java文件,实际上是关闭eclipse中所有不相关的项目。并尝试运行调试器。

#10


0  

I solved this problem by adding the class file into the src folder within the project. Hope this method may help.

我通过将类文件添加到项目中的src文件夹中解决了这个问题。希望这种方法有所帮助。

#11


0  

This is a common error while debug in eclipse. You can fix it through edit source look up. But make sure once you attach the Project You need to stop the server and again start in Debug mode. It will work.

这是eclipse中调试时的常见错误。您可以通过编辑源查找来修复它。但是确保一旦附加项目就需要停止服务器并再次以调试模式启动。它会工作。

Here is the detail steps :

这是详细步骤:

Click on "Edit Source Lookup Path" button . Then click on Add button. Select Java Project and include your imported project Then stop the server and start it in Debug mode and hit your service. It will work.

单击“编辑源查找路径”按钮。然后单击“添加”按钮。选择Java Project并包含导入的项目然后停止服务器并在调试模式下启动它并点击您的服务。它会工作。

#12


0  

I got this error when I was running my server using a maven tomcat plugin. When I deployed using my configured server in Eclipse (generating a war file and copying it into my tomcat directory), I didn't have this issue anymore.

当我使用maven tomcat插件运行我的服务器时出现此错误。当我在Eclipse中使用我配置的服务器部署(生成war文件并将其复制到我的tomcat目录中)时,我不再有这个问题了。

#13


0  

In your debug configuration add goals as "clean install"in the maven build con

在您的调试配置中,在maven build con中添加目标为“clean install”

#14


0  

This is an expansion on JAB's answer: Click "Edit Source Lookup..." > Add... > Workspace Folder > Project > select your folder > check Search subfolders box > OK.

这是对JAB答案的扩展:单击“编辑源查找...”>“添加...”>“工作区文件夹”>“项目”>选择文件夹>选中“搜索子文件夹”框>“确定”。

#1


21  

Sounds like the 'source lookup path' section if you edit the debug configuration isn't setup correctly?

如果编辑调试配置未正确设置,听起来像'源查找路径'部分?

#2


11  

Click on "Edit Source Lookup Path" button and then click on Add button then Java Project and include your imported project .. Hope this will solve your problem

单击“编辑源查找路径”按钮,然后单击“添加”按钮,然后单击“Java项目”并包含导入的项目..希望这将解决您的问题

#3


4  

I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild projet with

我的eclipse maven项目遇到了类似的问题。我和这个问题打了很长时间,然后我试着重建projet

mvn clean eclipse:eclipse

and it helped.

它帮助了。

#4


3  

I also had this issue in MyEclipse Blue. I resolved this one by following these steps:

我在MyEclipse Blue中也有这个问题。我按照以下步骤解决了这个问题:

  1. Debug the project.

    调试项目。

  2. Right click on the Thread (Which you will see in Debug tab) and click on the "Edit Source lookup"

    右键单击Thread(您将在Debug选项卡中看到),然后单击“Edit Source lookup”

  3. New window will open and hit the "Add" button and Select the "Java Project".

    将打开新窗口并单击“添加”按钮并选择“Java项目”。

  4. Get all the project that is listed over there.

    获取那里列出的所有项目。

  5. Restart your server.

    重启你的服务器。

#5


1  

We had the same problem and none of the suggestions above worked. What did work, was deleting the local workspace and from Eclipse checking out from the repository again. The problem occured for everybody previously working with Netbeans and making the switch to Eclipse.

我们遇到了同样的问题,上述建议都没有奏效。什么工作,是删除本地工作区和Eclipse再次从存储库中检出。以前使用Netbeans并切换到Eclipse的每个人都遇到了这个问题。

#6


1  

For local projects I've solved it by selecting the "Resolve Workspace artifacts" checkbox in the Debug Configurations.

对于本地项目,我通过选择Debug Configurations中的“Resolve Workspace artifacts”复选框来解决它。

#7


1  

When I faced this problem for the very first time, I've already done all the steps mentioned here. Curiously, my problem happened when I've copied a project into another place. Anyway, the debug starts to work without warnings, after simply remove all breakpoints that was originated from the original project. Sorry about my English , I'm not fluent.

当我第一次遇到这个问题时,我已经完成了这里提到的所有步骤。奇怪的是,当我将项目复制到另一个地方时,我的问题就发生了。无论如何,在简单地删除源自原始项目的所有断点之后,调试开始工作而没有警告。抱歉我的英语,我不会流利。

#8


1  

Try this:

  • Select Project
  • Right click
  • debug
  • Debug configuration
  • Select Source Tab
  • 选择Source选项卡

  • Click on add button
  • 单击“添加”按钮

  • Select Java Project
  • 选择Java Project

  • Add your project there with check box
  • 使用复选框添加项目

#9


1  

After trying most of the solutions here, try this too once -

在尝试了大多数解决方案后,尝试一次 -

Close all the .java files from the editor, in fact, close all unrelated projects in eclipse. And try running the Debugger.

从编辑器中关闭所有.java文件,实际上是关闭eclipse中所有不相关的项目。并尝试运行调试器。

#10


0  

I solved this problem by adding the class file into the src folder within the project. Hope this method may help.

我通过将类文件添加到项目中的src文件夹中解决了这个问题。希望这种方法有所帮助。

#11


0  

This is a common error while debug in eclipse. You can fix it through edit source look up. But make sure once you attach the Project You need to stop the server and again start in Debug mode. It will work.

这是eclipse中调试时的常见错误。您可以通过编辑源查找来修复它。但是确保一旦附加项目就需要停止服务器并再次以调试模式启动。它会工作。

Here is the detail steps :

这是详细步骤:

Click on "Edit Source Lookup Path" button . Then click on Add button. Select Java Project and include your imported project Then stop the server and start it in Debug mode and hit your service. It will work.

单击“编辑源查找路径”按钮。然后单击“添加”按钮。选择Java Project并包含导入的项目然后停止服务器并在调试模式下启动它并点击您的服务。它会工作。

#12


0  

I got this error when I was running my server using a maven tomcat plugin. When I deployed using my configured server in Eclipse (generating a war file and copying it into my tomcat directory), I didn't have this issue anymore.

当我使用maven tomcat插件运行我的服务器时出现此错误。当我在Eclipse中使用我配置的服务器部署(生成war文件并将其复制到我的tomcat目录中)时,我不再有这个问题了。

#13


0  

In your debug configuration add goals as "clean install"in the maven build con

在您的调试配置中,在maven build con中添加目标为“clean install”

#14


0  

This is an expansion on JAB's answer: Click "Edit Source Lookup..." > Add... > Workspace Folder > Project > select your folder > check Search subfolders box > OK.

这是对JAB答案的扩展:单击“编辑源查找...”>“添加...”>“工作区文件夹”>“项目”>选择文件夹>选中“搜索子文件夹”框>“确定”。