英文:
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 没有特殊配置。
我的问题是:
- 为什么这些在构建路径中没有显示为不正确的库依赖项?
- 特别是在涉及到 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:
<?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>
and .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>
Regarding the Application Server, I checked with test environment, there is nothing special configured for Tomcat.
My questions are :
- how can it be that these are not visible as incorrect libary dependencies in the build path?
- 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:
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>.
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\
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论