Maven项目无法产生Maven Dependencies且无法update project报cannot nest错误

43 篇文章 0 订阅
19 篇文章 0 订阅

这两天要导入公司的项目,熟悉框架,结果导了很多遍,都出现这个问题,上网找了很多,

有说这个解决方法的:

solution:

这往往是由于 web project的Maven选项 未启动(disable) 造成的;

我们只需要重启 Maven Dependency就行,

操作方式: 右击 web project -->  Properties --> Macven --> Enable Dependency Management 

不知道是不是因为我的Maven版本是3,所以我压根不会出现Enable Dependency Management这个选项

最后我对比了一个没有出错的项目的.classpath文件,ctrl+f找maven,把对的那个项目的.classpath文件中有maven的全都粘到出错的项目中,然后refresh项目,发现出现了Maven Dependencies这个库!

后来再上网搜索,找到了解决办法:

找自己出错项目的.classpath文件,打开,ctrl+f,找是否有以下文件,如果没有在末尾加进去,再refresh项目即可:

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">  
  2.         <attributes>  
  3.             <attribute name="maven.pomderived" value="true"/>  
  4.             <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>  
  5.         </attributes>  
  6. </classpathentry>  

添加后我的.classpath文件是这样的:

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <classpath>  
  2.     <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources/base">  
  3.         <attributes>  
  4.             <attribute name="maven.pomderived" value="true"/>  
  5.         </attributes>  
  6.     </classpathentry>  
  7.     <classpathentry kind="src" path="src/main/java/base"/>  
  8.     <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources/ff.zqgame.com">  
  9.         <attributes>  
  10.             <attribute name="maven.pomderived" value="true"/>  
  11.         </attributes>  
  12.     </classpathentry>  
  13.     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">  
  14.         <attributes>  
  15.             <attribute name="maven.pomderived" value="true"/>  
  16.         </attributes>  
  17.     </classpathentry>  
  18.     <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">  
  19.         <attributes>  
  20.             <attribute name="maven.pomderived" value="true"/>  
  21.             <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>  
  22.         </attributes>  
  23.     </classpathentry>  
  24.     <classpathentry kind="output" path="target/classes"/>  
  25. </classpath>  

项目没有问题啦!开心!

项目加载是要读取.classpath文件的,加载不到且Maven不能update project说cannot nest错误。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值