如何在 Eclipse 中的调试配置的类路径中添加 Maven 依赖项?

问题描述 投票:0回答:1

我是 Maven 新手,我正在使用 Eclipse 和 m2eclipse 插件。我创建了一个 webapp Maven 项目。我在我的

pom.xml
中添加了几个依赖项,并且依赖项得到了解决。我在 Maven 构建实用程序上执行了
clean install
。源代码已正确编译。

eclipse screenshot

但是如果我想运行或调试 Web 应用程序,我无法在类路径中添加 amven 依赖项。例如,如果我创建一个新的调试配置,我会转到类路径部分,但无法查看用户条目中列出的 Maven 依赖项。如果我尝试通过依次单击 AdvancedLibraryMaven Managed Dependencies 添加它们,我会收到警报“使用 Maven 项目设置来配置 Maven 依赖项解析”。

eclipse screenshot

eclipse maven debugging dependencies
1个回答
0
投票

我在将 Maven 项目导入 Eclipse 时遇到了同样的问题。 Eclipse 无法为某些 Maven 项目添加 Maven 依赖项库。我通过比较 eclipse 能够添加 Maven 依赖项的项目的 .class 文件发现了这一点。

并更新了我的项目的 .class 文件,如下所示:并且它有效。

<?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/JDK"/>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src/test"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <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 v9.0"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
© www.soinside.com 2019 - 2024. All rights reserved.