Web 应用程序中 JAR 清理的方法

发布于 2024-10-04 20:09:07 字数 135 浏览 1 评论 0原文

在具有大量依赖项的大型项目中,WEB-INF/lib 文件夹通常挤满了 jar 文件。我真的感觉比我们用的还多很多。

随着我们的项目接近生产,是时候进行清理了。但是是否有一种工具或方法可以进行此清理并确保(或最大化机会)代码中没有任何内容?

In big projects, with lots of dependencies, the WEB-INF/lib folder is often crowded with jars. I really feel that there is a lot more than we use.

As our project is getting close to production, it's time for a cleanup. But is there a tool, or a method, for doing this cleanup and ensuring (or maximizing the chances) that nothing breaks in the code ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不喜欢何必死缠烂打 2024-10-11 20:09:07

这几乎是不可能的。可能存在通过反射访问的依赖项。没有任何静态代码分析器可以可靠地检查这一点。

您最好的选择实际上是删除所有 JAR 和单元测试(如果尚未完成,则创建单元测试),直到您收到 ClassNotFoundExceptionNoClassDefFoundError 然后添加包含相关类的 JAR。

为了避免将来出现此类问题,请考虑使用依赖关系管理器,例如 Maven常春藤

That's almost impossible. There may be dependencies which are accessed by reflection. No one static code analyzer can check this reliably.

Your best bet is really to remove all the JAR's and unit-test (create unit tests if not done yet) as long as until you get a ClassNotFoundException or NoClassDefFoundError and then add the JAR containing the class in question.

To avoid this kind of problems in the future, consider a dependency manager like Maven or Ivy.

回首观望 2024-10-11 20:09:07

您可以使用 http://classpathhelper.sourceforge.net/ 等工具,但正如 BalusC 所说,这是不可能的查找使用反射加载的类。

You can use a tool as http://classpathhelper.sourceforge.net/, but as BalusC said is not possible to find the classes loaded using reflection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文