1、eclipse libraries 不存在maven的依赖包时
1、第一步
项目右键-》Build Path -》 Java Build Path -》Libraries -》Add Library -》Maven Managed Dependences-》点击Next -》点击‘Maven Project settings’ , 在‘Active Maven Profiles (comma separated)’中添加“Maven Dependencies”确认即可。
2、第二步
.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>
重启eclipse,查看上述两个步骤,会看到maven dependencies出现了,报的错消失了
2、maven 找不到或无法加载主类
1.报错原因:
maven的测试类,默认的存放路径为:项目名/target/test/test-classe,
如果修改了测试文件的默认编译位置,在运行测试类时,maven项目还是去默认的路径下找该类的class文件,这时候肯定找不到,所以报错
2.解决方案:
将Java类的默认编译位置还原
勾选上"Allow output for source folders"–>双击"Output folder:()"–>编译位置改为"target/classes"即可。
剩余那3项也需要进行手动修改。
4.src/main/java,src/main/resources,src/test/java,src/test/resources的默认编译位置图示
3、解决:No goals have been specified for this build. You must specify a valid lifecycle phase or a goal i
pom.xml 文件中 <build>
标签要加配置: <defaultGoal>
compile</defaultGoal>
4、Eclipse创建maven工程后没有build path解决方案
修改一下文件
1、创建项目下的.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<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>
<classpathentry kind="output" path="bin"/>
</classpath>
2、.project
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<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>
<classpathentry kind="output" path="bin"/>
</classpath>