eclipse 导入maven工程 在libraries 没有maven Dependencies显示的是 org.eclipse.ide.MAVEN2_CLASSPATH_CONTAINER

本文介绍了解决Maven项目中依赖包未能正确加载的问题,并详细解析了.classPath文件的作用及其配置方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、这两天遇到了个问题就是导入maven工程的时候所有的依赖包下载不下来,最后而且在工程的buildPath====>java BuildPath====>libraries 中没有maven Dependencies,这显得maven项目很奇怪,最后经过查找问题,发现在你本地的工程目录中的.classPath是有问题的,这个文件是决定工程目录结构的

将.classPath打开跟其他正常工程比较发现缺少

<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>


加上 将工程clean后就发现在libraries 有maven Dependencies显示了。

2、对于这个.classPath文件里面内容的解析

定义项目的结构,如src、output、con、lib等。 

源文件的具体位置(kind="src")

运行的系统环境(kind="con")

工程的library的具体位置信息(kind="lib")

在每个lib的xml子节点中,有关于它的其它配置信息(例如我配置的那个"javadoc_location")

项目的输出目录(kind="output")

样本:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
 <classpathentry kind="src" output="target/classes" path="src/main/java">
  <attributes>
   <attribute name="optional" value="true"/>
   <attribute name="maven.pomderived" value="true"/>
  </attributes>
 </classpathentry>
 <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
  <attributes>
   <attribute name="maven.pomderived" value="true"/>
  </attributes>
 </classpathentry>
 <classpathentry kind="src" output="target/test-classes" path="src/test/java">
  <attributes>
   <attribute name="optional" value="true"/>
   <attribute name="maven.pomderived" value="true"/>
  </attributes>
 </classpathentry>
 <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
  <attributes>
   <attribute name="maven.pomderived" value="true"/>
  </attributes>
 </classpathentry>
 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
  <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"/>
  </attributes>
 </classpathentry>
 <classpathentry kind="output" path="target/classes"/>
</classpath>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值