Eclipse里调试时遇到Source not found应该怎么办

When you are debugging in Eclipse, sometimes when you debug into a method, you will meet with “Source not found” message, for example below.

Eclipse里调试时遇到Source not found应该怎么办
Eclipse里调试时遇到Source not found应该怎么办

In my example, this is because the corresponding source code for AbstractTypeHierarchyTraversingFilter does not exist in local workspace. The source code could not be automatically downloaded via “Maven -> Download Sources”.

[Note] This very issue in this example could also be resolved by changing dependency configuration in pom.xml. Please read this blog about what exactly should be defined in pom.xml if different Spring component is planned to be used in your application. In my example, after I add the missing dependency “spring-core” in pom.xml and re-download source via Maven plugin, the source code is then visible in debugger.

Eclipse里调试时遇到Source not found应该怎么办

Solution

(1) Google with keyword as below:

Eclipse里调试时遇到Source not found应该怎么办

Click the first hit web page.
(2) Go to the corresponding download page for your spring framework version:

Eclipse里调试时遇到Source not found应该怎么办

You could find your Spring version in pom.xml, dependency block:

Eclipse里调试时遇到Source not found应该怎么办

(3) Download the .java source file.
Create a series of nested folders whose hierarchy exactly match the package declaration in java file. In my example, the folder structure should look like below:
Eclipse里调试时遇到Source not found应该怎么办

Then make a zip file based on this folder.
(4) Click “Change Attached Source…” to load the zip file created in step3.

Eclipse里调试时遇到Source not found应该怎么办
Eclipse里调试时遇到Source not found应该怎么办

After that the source code of AbstractTypeHierarchyTraversingFilter is visible in debugger now.

Eclipse里调试时遇到Source not found应该怎么办

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
Eclipse里调试时遇到Source not found应该怎么办