Eclipse 项目中不必要的 JAR - 潜在问题?
我的工作空间中有 5-6 个项目,其中许多项目是相互依赖的。
我通常只是将其他项目 lib
目录中所有可能的 JAR 放入当前项目的构建路径中,而不去检查哪些是构建所必需的。
鉴于每个项目中有几十个 JAR,这种方法会导致问题吗?
I have 5-6 projects in my workspace, many of which are interdependent.
I usually just put all possible JARs from other projects lib
dir into the build path of the current project, without bothering to check which is necessary for the build.
Can this approach cause problems, given that there are some few dozens of JARs in each project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我同意 @m0skit0 的观点,并且可以添加到延续中,您应该尽最大努力删除您并不真正使用的库。
手动完成可能非常困难。因此,更好的方法是使用自动依赖关系管理。 Maven 和 Gradle 完美地完成了这项工作。您只需提到第一级依赖项(您应该知道)。他们关心第二、第三等级别的依赖关系。您永远不会更新您的
lib
目录。构建工具会自动更新您的本地存储库。I agree with @m0skit0 and can add into continuation that you should do you best effort to remove libraries you do not really use.
It may be very difficult to do manually. So, better way is to use automatic dependencies management. Maven and Gradle do this job perfectly. You just mention the first level dependencies (that you should know). They care about the second, third etc. level dependencies. You never update your
lib
directory. The build tool updates your local repository automatically.我希望您所说的相互依赖并不是指存在循环依赖。这将是一个很大的不!
如果您的依赖关系不是循环的,那么我没有看到任何问题。无论如何,您都需要运行时类路径中的所有这些 jar 来运行程序。您可能想要避免的是项目 A 的代码中对项目 B 使用的库“old_library_still_needed_by_project_B_but_that_should_not_be_used_anymore.jar”有一些直接依赖关系,但是有静态 Java 代码分析工具(可以检查一些类或包)从未在项目源代码中使用),例如 CheckStyle 和 PMD。
By interdependent, I hope you don't mean that you have circular dependencies. This would be a big NO!
If your dependencies are not cyclic, then I don't see any problem. You'll need all those jars in the runtime classpath anyway to run the program. What you might want to avoid is to have some direct dependencies in the code of project A to a library "old_library_still_needed_by_project_B_but_that_should_not_be_used_anymore.jar" used by project B, but there are static Java code analysis tools for this (which can check the some classes or packages are never used inside a project source code), like CheckStyle and PMD.