如何识别项目中包含的不必要的罐子?

时间:2022-03-15 10:36:31

I'm working in a Java project where the axis 2 library from Apache is being used. The axis 2 library is composed of about 20 jar files and some of these are not used project. What I want to know if there is a method to identify which of those jar files are the unused ones.

我正在一个Java项目中工作,其中使用了Apache的axis 2库。轴2库由大约20个jar文件组成,其中一些不用于项目。如果有一种方法可以识别哪些jar文件是未使用的文件,我想知道什么。

I'm using the Eclipse IDE an I thought that one way to solve the problem is to add one jar at time until the I get no error messages about the missing classes. However, I'm not sure if this will work as some of the missing classes errors show up only at runtime.

我正在使用Eclipse IDE,我认为解决问题的一种方法是在时间上添加一个jar,直到我没有得到关于缺失类的错误消息。但是,我不确定这是否会起作用,因为一些缺少的类错误仅在运行时出现。

Does anyone know a better way to solve this problem?

有谁知道更好的方法来解决这个问题?

3 个解决方案

#1


tattletale FTW

http://www.jboss.org/tattletale

JBoss Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on.

JBoss Tattletale是一个工具,可以帮助您了解您正在进行的项目或您所依赖的产品。

The tool will provide you with reports that can help you

该工具将为您提供可以帮助您的报告

  • Identify dependencies between JAR files
  • 识别JAR文件之间的依赖关系

  • Spot if a class is located in multiple JAR files
  • 如果一个类位于多个JAR文件中,请发现

  • Spot if the same JAR file is located in multiple locations
  • 如果相同的JAR文件位于多个位置,请发现

  • With a list of what each JAR file requires and provides
  • 列出每个JAR文件所需和提供的内容

#2


I would follow your original idea of adding one jar at time until it compiles.

我会遵循你最初的想法,即添加一个罐子直到它编译。

You're right that you can still find run-time errors, but unless the application is too big for a good coverage with manual tests, I would simply run and test it to add any missing jars.

你是对的,你仍然可以找到运行时错误,但除非应用程序太大而无法通过手动测试获得良好的覆盖率,否则我只需运行并测试它以添加任何丢失的jar。

#3


I don't think you can reliably remove jars since classes may be resolved at runtime e.g. using

我不认为你可以可靠地删除罐子,因为类可以在运行时解决,例如运用

Class.forName(className);

You may be able to determine the class names used for the above, but it's unlikely.

您可能能够确定用于上述的类名,但这不太可能。

Since classes will be requested/resolved at runtime, you could run your (comprehensive) test suite to determine whether stuff still works. But ultimately I would be very wary of removing jars from a package like Axis. I assume they're there for a purpose. Is the jar file size really a problem ?

由于将在运行时请求/解析类,因此您可以运行(综合)测试套件来确定是否仍然有效。但最终我会非常谨慎地从像Axis这样的软件包中删除jar。我认为他们是出于某种目的。 jar文件大小真的有问题吗?

#1


tattletale FTW

http://www.jboss.org/tattletale

JBoss Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on.

JBoss Tattletale是一个工具,可以帮助您了解您正在进行的项目或您所依赖的产品。

The tool will provide you with reports that can help you

该工具将为您提供可以帮助您的报告

  • Identify dependencies between JAR files
  • 识别JAR文件之间的依赖关系

  • Spot if a class is located in multiple JAR files
  • 如果一个类位于多个JAR文件中,请发现

  • Spot if the same JAR file is located in multiple locations
  • 如果相同的JAR文件位于多个位置,请发现

  • With a list of what each JAR file requires and provides
  • 列出每个JAR文件所需和提供的内容

#2


I would follow your original idea of adding one jar at time until it compiles.

我会遵循你最初的想法,即添加一个罐子直到它编译。

You're right that you can still find run-time errors, but unless the application is too big for a good coverage with manual tests, I would simply run and test it to add any missing jars.

你是对的,你仍然可以找到运行时错误,但除非应用程序太大而无法通过手动测试获得良好的覆盖率,否则我只需运行并测试它以添加任何丢失的jar。

#3


I don't think you can reliably remove jars since classes may be resolved at runtime e.g. using

我不认为你可以可靠地删除罐子,因为类可以在运行时解决,例如运用

Class.forName(className);

You may be able to determine the class names used for the above, but it's unlikely.

您可能能够确定用于上述的类名,但这不太可能。

Since classes will be requested/resolved at runtime, you could run your (comprehensive) test suite to determine whether stuff still works. But ultimately I would be very wary of removing jars from a package like Axis. I assume they're there for a purpose. Is the jar file size really a problem ?

由于将在运行时请求/解析类,因此您可以运行(综合)测试套件来确定是否仍然有效。但最终我会非常谨慎地从像Axis这样的软件包中删除jar。我认为他们是出于某种目的。 jar文件大小真的有问题吗?