如何将源代码附加到Eclipse中的项目库中? [英] How do I attach source code into a project's library in Eclipse?
问题描述
我在Eclipse中创建了一个简单的独立Spring应用程序,作为 Java应用程序(并且不使用maven或gradle)。我手动下载了所需的Spring框架jar,应用程序运行正常。
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.
现在,我想调试代码并查看Spring源代码中的代码流。因此我下载了Spring的源代码,作为Zip文件。我在文件系统的特定位置解压缩了源代码。
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.
现在,如何将Spring源代码添加到项目中?
Now, how do I add the Spring source code into the project?
我做的一些事情如下:
1)我试图使用 import-> existing ..
,但它没有用,因为Spring源现在是Gradle项目。
1) I tried to use the import->existing..
, however it didn't work, as the Spring source are now as Gradle project.
2)在调试期间,它要求附加源,它以某种方式工作,但它不符合我的意图。基本上我想调试代码 AutowiredAnnotationBeanPostProcessor.java
,我想把断点放在这段代码上。此源属于 @Autowired
注释,因此我无法即时附加源。因此我的目的是预先放置断点并查看控件是如何进行的。
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 AutowiredAnnotationBeanPostProcessor.java
and I want to put the breakpoint on this code. This source belong to the @Autowired
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.
有没有办法附加Spring的所有源代码(即所有模块的Spring)正在开发的应用程序(并且应用程序不是基于maven / gradle)。
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).
我确实检查了各种SO问题而我没有得到我的答案因此发布新问题。
I did check various SO questions and I didn't get my answer and hence posting new question.
推荐答案
首先,没有什么可以在 @ Autowire 是只是一个注释。你唯一能看到的就是它的属性。而已。有趣的代码在 AutowiredAnnotationBeanPostProcessor.java
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 AutowiredAnnotationBeanPostProcessor.java
无论如何,如果你想将源拉链附加到jar。在Eclipse中就像这样简单:
Anyways, if you want to attach source zips to a jar. In Eclipse is as easy as:
- 您的项目(右键单击)> 偏好
- 选择 Java构建路径(左侧菜单)> 库(Tab)
- 查找jar点击在它的箭头
- 选择来源附件
- Your Project (Right Click) > Preference
- Select Java Build path (Left menu) > Libraries (Tab)
- Look for the jar an do click on its arrow
- Select source attachement
这里一个<该过程的href =http://pdplab.it.uom.gr/teaching/sunjava/eclipse-java_files/add_source_to_jar.jpg =nofollow>示例。
如果您对Annotations的工作原理感兴趣。我建议本教程 Java Tutorial - Annotations 。
If you are insterested on how Annotations works. I suggest this tutorial Java Tutorial - Annotations.
这篇关于如何将源代码附加到Eclipse中的项目库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!