Eclipse在引入或创建Maven工程后,在其build环境中不显示Maven Dependencies,同时maven install执行不报错,在网上搜了这个问题,大多都是下面这种做法:
右击项目 -> Maven --> Enable DependencyManagement ,但是这种方法有时候是行不通的。
你可以试试:右击项目 -> Maven -->UpdateProject ,如果Update Project之后依然没有出现Maven Dependencies依赖库的话,那么你的问题应该是因为eclipse的maven插件与你所安装的maven版本不兼容所导致的,此时应该重建classpath文件,在classpath中添加:
<classpathentry exported="true" 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>
之后重启eclipse,最好再Maven -->Update Project一下,或者update project。问题解决。
附完整的classpath(直接全部覆盖即可)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/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.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"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="src/main/webapp/WEB-INF/classes"/>
</classpath>