eclipse - 如何指示 Eclipse 记录外部 jars 的相对路径?

标签 eclipse

这是我的 .classpath 文件,在我添加了另外两个外部 jar(org.reSTLet.ext.simple.jar 和 org.simpleframework.jar)之后:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.jackson.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
        <attributes>
            <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.ssl.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
        <attributes>
            <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
        <attributes>
            <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/api"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.jsslutils_1.0/org.jsslutils.jar"/>
    <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.core.jar"/>
    <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.mapper.jar"/>
    <classpathentry kind="lib" path="../3rd_party/guice-3.0/aopalliance.jar"/>
    <classpathentry kind="lib" path="../3rd_party/guice-3.0/guice-3.0.jar"/>
    <classpathentry kind="lib" path="../3rd_party/guice-3.0/javax.inject.jar"/>
    <classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.simple.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
        <attributes>
            <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.simpleframework_4.1/org.simpleframework.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

请注意,它们已添加了绝对路径,这与其他具有相对路径的条目不同,但这仅仅是因为每次添加新的外部 jar 时我都会手动编辑此文件。

我的问题是我可以以某种方式告诉 Eclipse 使用新添加的外部 jar 的相对路径吗?

谢谢。

最佳答案

一种解决方案是不使用外部 jar,而是将 jar 放入项目中,然后使用 Add Jar(s) 而不是 Add External Jar(s)。

从源代码控制的角度来看,这是有道理的,您可以根据需要添加/删除依赖项。这也意味着当你为一个单独的项目更新一个 jar 时,它不会影响这个。

我们过去已经这样做了,我们有一个包含所有 jars 的单个项目,这些 jars 在其他项目的构建路径中被引用。

但是现在我们使用maven,所以我们不再需要这样做了。

关于eclipse - 如何指示 Eclipse 记录外部 jars 的相对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8317957/

相关文章:

java - 如何解决SONAR LINT中的 "Unable to update binding"错误?

java - TCP 连接期间应用程序崩溃

java - 断点未在 maven 多模块 Web 应用程序的 eclipse 中注册

android - 从 Eclipse 调试 Honeywell Dolphin

java - 如何说服 Eclipse 提供非必需的方法?

eclipse - 如何拒绝maven使用Eclipse中打开的项目而不是存储库中的jar

java - "download-maven-plugin"- 要下载多个文件并重新定位输出目录

eclipse - 使用自定义 ecore 元模型进行 Acceleo 转换

java - 关于 Java 中私有(private)静态嵌套类的合成访问器的 Eclipse 警告?

java - Eclipse CTRL+SPACE 删除文本