如何查找在 Eclipse 项目中使用的 JAR 版本。

huangapple go评论78阅读模式
英文:

How to find out which versions of JARs were used in the eclipse project

问题

以下是翻译好的部分:

我继承了一个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>

关于应用服务器,我在测试环境中进行了检查,Tomcat 没有特殊配置。

我的问题是:

  1. 为什么这些在构建路径中没有显示为不正确的库依赖项?
  2. 特别是在涉及到 CXF 时,有没有办法找出使用了哪个版本?

希望这些信息能对你有所帮助。

英文:

I have inherited an eclipse project which has a couple of dependencies. There is no documentation and the maintainer is no longer available.
Some of them were referenced in the project setup and I could just download the correct jars and add them. There are no further references in the build path.
But now I see that there are still imports in the source code which are unresolved, like

import org.apache.cxf.*;
import javax.servlet.ServletContextEvent;
import javax.servlet.http.HttpServletRequest;

Here is the .project:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;projectDescription&gt;
	&lt;name&gt;Server&lt;/name&gt;
	&lt;comment&gt;&lt;/comment&gt;
	&lt;projects&gt;
	&lt;/projects&gt;
	&lt;buildSpec&gt;
		&lt;buildCommand&gt;
			&lt;name&gt;org.eclipse.wst.jsdt.core.javascriptValidator&lt;/name&gt;
			&lt;arguments&gt;
			&lt;/arguments&gt;
		&lt;/buildCommand&gt;
		&lt;buildCommand&gt;
			&lt;name&gt;org.eclipse.jdt.core.javabuilder&lt;/name&gt;
			&lt;arguments&gt;
			&lt;/arguments&gt;
		&lt;/buildCommand&gt;
		&lt;buildCommand&gt;
			&lt;name&gt;org.eclipse.wst.common.project.facet.core.builder&lt;/name&gt;
			&lt;arguments&gt;
			&lt;/arguments&gt;
		&lt;/buildCommand&gt;
		&lt;buildCommand&gt;
			&lt;name&gt;org.eclipse.wst.validation.validationbuilder&lt;/name&gt;
			&lt;arguments&gt;
			&lt;/arguments&gt;
		&lt;/buildCommand&gt;
	&lt;/buildSpec&gt;
	&lt;natures&gt;
		&lt;nature&gt;org.eclipse.jem.workbench.JavaEMFNature&lt;/nature&gt;
		&lt;nature&gt;org.eclipse.wst.common.modulecore.ModuleCoreNature&lt;/nature&gt;
		&lt;nature&gt;org.eclipse.wst.common.project.facet.core.nature&lt;/nature&gt;
		&lt;nature&gt;org.eclipse.jdt.core.javanature&lt;/nature&gt;
		&lt;nature&gt;org.eclipse.wst.jsdt.core.jsNature&lt;/nature&gt;
	&lt;/natures&gt;
&lt;/projectDescription&gt;

and .classpath:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;classpath&gt;
	&lt;classpathentry kind=&quot;src&quot; path=&quot;src&quot;/&gt;
	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jst.j2ee.internal.web.container&quot;/&gt;
	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jst.j2ee.internal.module.container&quot;/&gt;
	&lt;classpathentry kind=&quot;lib&quot; path=&quot;WebContent/WEB-INF/lib/sqljdbc4.jar&quot;&gt;
		&lt;attributes&gt;
			&lt;attribute name=&quot;org.eclipse.jst.component.dependency&quot; value=&quot;/WEB-INF/lib&quot;/&gt;
		&lt;/attributes&gt;
	&lt;/classpathentry&gt;
	&lt;classpathentry exported=&quot;true&quot; kind=&quot;con&quot; path=&quot;org.eclipse.jst.ws.cxf.core.CXF_CLASSPATH_CONTAINER&quot;&gt;
		&lt;attributes&gt;
			&lt;attribute name=&quot;org.eclipse.jst.component.dependency&quot; value=&quot;/WEB-INF/lib&quot;/&gt;
		&lt;/attributes&gt;
	&lt;/classpathentry&gt;
	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0&quot;/&gt;
	&lt;classpathentry kind=&quot;lib&quot; path=&quot;C:/Users/xxxx/Desktop/Server/src/libs/fontbox-1.8.16.jar&quot;/&gt;
	&lt;classpathentry kind=&quot;lib&quot; path=&quot;C:/Users/xxxx/Desktop/Server/src/libs/pdfbox-1.8.16.jar&quot;/&gt;
	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot;&gt;
		&lt;attributes&gt;
			&lt;attribute name=&quot;owner.project.facets&quot; value=&quot;java&quot;/&gt;
		&lt;/attributes&gt;
	&lt;/classpathentry&gt;
	&lt;classpathentry kind=&quot;lib&quot; path=&quot;C:/Users/xxxx/Desktop/Server/src/libs/log4j-1.2.17.jar&quot;/&gt;
	&lt;classpathentry kind=&quot;lib&quot; path=&quot;C:/Users/xxxx/Desktop/Server/src/libs/commons-lang-2.6.jar&quot;/&gt;
	&lt;classpathentry kind=&quot;output&quot; path=&quot;build/classes&quot;/&gt;
&lt;/classpath&gt;

Regarding the Application Server, I checked with test environment, there is nothing special configured for Tomcat.

My questions are :

  1. how can it be that these are not visible as incorrect libary dependencies in the build path?
  2. especially when it comes to cxf, is there a way to find out which version was used?

答案1

得分: 1

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 > Preferences > CXF Runtime。从您提供的信息中无法推断出具体的版本。您可以在这里查看:https://cxf.apache.org/download.html

考虑升级 Java、Tomcat 和 CXF 到更新的版本,因为 Tomcat 6 旧版本已于2017年停止维护。

注意:当构建项目时,所需的 CXF JAR 包应该出现在 /WEB-INF/lib 目录下。如果您在 Eclipse 中的服务器上运行,它们将被放置在临时文件夹中,类似于:

    [工作空间]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\WebServiceProject\WEB-INF\lib\
英文:

The javax.servlet is versione 2.5 in Tomcat 6 from your configuration:

 &lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0&quot;/&gt;.

and your application should simply depend on the jars included in Tomcat.

For the CXF I think you should first add a CXF runtime to your Eclipse under: Preferences > WebServices > CXF.2 Preferences > CXF Runtime. The specific version cannot be deducted from what you reported. You can look here: https://cxf.apache.org/download.html

You should consider upgrading Java, Tomcat and CXF to newer versions, since Tomcat 6 is old and in end of life since 2017.

Note: when you build your project the required CXF jars should end up in /WEB-INF/lib in you war. If you run in a Server in Eclipse they will be placed in a temproary folder, something like:

[WORKSPACE]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\WebServiceProject\WEB-INF\lib\

huangapple
  • 本文由 发表于 2020年4月9日 15:15:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/61115808.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定