eclipse导入maven项目,把src/main, src/test直接解析成包名的错误

eclipse导入maven项目,把src/main, src/test直接解析成包名的错误
强烈推介IDEA2021.1.3破解激活,IntelliJ IDEA 注册码,2021.1.3IDEA 激活码  

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说eclipse导入maven项目,把src/main, src/test直接解析成包名的错误,希望能够帮助大家进步!!!

把资源文件src/main等都解析成java package名mian.xx.xx 导致整个工程都报错,解决方法是:

  1. 点击工程右键–> maven -->update project

  2. 如果第一步不行的话,则要修改.classpath文件,修改后文件为:

<?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 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>  
本文来源GroovRain,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/25370

发表评论