CuriousMind CuriousMind - 5 months ago 17x
Java Question

How do I attach source code into a project's library in Eclipse?

I created a simple standalone Spring application in Eclipse as a Java application (and not using maven or gradle). I manually downloaded the needed Spring framework jars, and the application works fine.

Now, I wanted to debug the code and see the flow of code inside the Spring source as well. Hence I downloaded the source code of Spring , as a Zip file. I extracted the source code in a specific location in the file system.

Now, how do I add the Spring source code into the project?

Some of the things that i did are as below:

1) I tried to use the

, however it didn't work, as the Spring source are now as Gradle project.

2) During debug, it asks for attaching the source, it works in a way, however it doesn't fulfill what I intend to. Basically I want to debug the code
and I want to put the breakpoint on this code. This source belong to the
annotation and hence I won't be able to attach the source on-the-fly. Hence my intention is to pre place the breakpoint and see how the control goes in there.

Is there any way to attach ALL source code of Spring (i.e., all modules of Spring) to the application being developed (and the application isn't based on maven / gradle).

I did check various SO questions and I didn't get my answer and hence posting new question.


First of all, there's nothing to be debuged at @Autowire is just an annotation. The only thing you will see there is its attributes. That's it. The interesting code is in

Anyways, if you want to attach source zips to a jar. In Eclipse is as easy as:

  1. Your Project (Right Click) > Preference
  2. Select Java Build path (Left menu) > Libraries (Tab)
  3. Look for the jar an do click on its arrow
  4. Select source attachement

Here an example of the process.

If you are insterested on how Annotations works. I suggest this tutorial Java Tutorial - Annotations.