methodology for JAR cleanup in a web app
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 th开发者_JAVA技巧is cleanup and ensuring (or maximizing the chances) that nothing breaks in the code ?
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.
You can use a tool as http://classpathhelper.sourceforge.net/, but as BalusC said is not possible to find the classes loaded using reflection.
精彩评论