我正在使用 Eclipse IDE 及其衍生产品(如 Spring IDE)进行 Java 开发。
在 Web 应用程序项目中,我将 Spring MVC jars、Apache commons jars 等外部 jar 添加到 Web App 库文件夹,因此它们会自动添加到构建路径。 Web App库文件夹中有很多jar。
我想在项目中创建文件夹并添加 Web App 库文件夹中包含的库的所有源文件 (zip/jar),以便我可以从 Java 编辑器窗口浏览库的源代码。每当我将源 zip/jar 文件添加到此文件夹时,Eclipse 应该会检测到它并在我想导航到库的源时使用它。
在 eclipse 中可以实现以上吗?
Note: I know how to add source files for each individual jar by navigating to the build path window and specifying the source location. But this is very crude way, and I need to do for every library individually. Also the drawback is that source path is absolute, which means if I import the project into another computer then I need to create the source path or even worse I might have to add the source files individually again.
最佳答案
自动获取 jar 源的一种方法是某种依赖管理系统。大多数人现在会尖叫 Maven (2/3),但其他人存在并且运行良好。 Maven 确实有很好的 Eclipse 集成,所以这应该是一个加号。
不利的是,仅仅为了依赖管理而设置 Maven 项目似乎有点过分了。另一点是,您依赖的所有 jar 也应该是“Mavenized”。
据我所知,Eclipse 不会自动检测/扫描源存档文件并按照您描述的方式将它们链接到您工作区中的库。
关于java - 如何添加库jar的源文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5803740/