java - 如何找出 Eclipse 项目中使用了哪些版本的 JAR
问题描述
我继承了一个 Eclipse 项目,它有几个依赖项。没有文档,维护者不再可用。其中一些在项目设置中被引用,我可以下载正确的 jar 并添加它们。构建路径中没有进一步的引用。但是现在我看到源代码中仍然存在未解决的导入,例如
import org.apache.cxf.*;
import javax.servlet.ServletContextEvent;
import javax.servlet.http.HttpServletRequest;
这是.project:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Server</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
和.classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/sqljdbc4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.ws.cxf.core.CXF_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
<classpathentry kind="lib" path="C:/Users/xxxx/Desktop/Server/src/libs/fontbox-1.8.16.jar"/>
<classpathentry kind="lib" path="C:/Users/xxxx/Desktop/Server/src/libs/pdfbox-1.8.16.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/xxxx/Desktop/Server/src/libs/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="C:/Users/xxxx/Desktop/Server/src/libs/commons-lang-2.6.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
关于Application Server,我检查了测试环境,Tomcat没有什么特别的配置。
我的问题是:
- 怎么可能这些在构建路径中不可见为不正确的库依赖项?
- 特别是当涉及到 cxf 时,有没有办法找出使用了哪个版本?
解决方案
javax.servlet 在您的配置中是 Tomcat 6 中的 2.5 版本:
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>.
并且您的应用程序应该只依赖于 Tomcat 中包含的 jar。
对于 CXF,我认为您应该首先在 Eclipse 中添加一个 CXF 运行时:Preferences > WebServices > CXF.2 Preferences > CXF Runtime。不能从您报告的内容中扣除具体版本。你可以看这里:https ://cxf.apache.org/download.html
您应该考虑将 Java、Tomcat 和 CXF 升级到较新的版本,因为 Tomcat 6 已经过时并且自 2017 年起就已终止使用。
注意:当您构建项目时,所需的 CXF jar 应该在您的战争中以 /WEB-INF/lib 结束。如果您在 Eclipse 中的服务器中运行,它们将被放置在一个临时文件夹中,例如:
[WORKSPACE]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\WebServiceProject\WEB-INF\lib\
推荐阅读
- php - Swagger-php 如何排除整个 /vendor 文件夹但附加一个带有共享模型的子文件夹
- bash - 在 jenkins 中使用脚本在不同阶段运行
- makefile - 相同的规则,不同的先决条件
- javascript - 用户使用框架 7 关闭应用程序后如何维护用户会话?
- c# - Rx Extensions 刷新 Buffered observable 中的剩余项目
- c++ - D 和 C++ 目前的互操作性状态
- javascript - 如何从日期类型输入元素中获得最终日期选择?
- python - 具有多个可调用对象的 df.loc[]
- java - 关于 Java Web 应用程序“堆空间内存”错误,如何增加 Google App Engine 开发服务器内存大小?
- docker - 在构建 docker/gcloud 上保留目录