[转载]maven eclipse 工程缺少build path怎么办?

现象

在eclipse里用subeclipe从svn上拖下来的项目,看不见java build path怎么办?

原因

那是因为你的两个配置文件:.project .classpath没有内容或者缺失。

解决

以一个maven管理的java项目为例。

用下面内容替换掉.project文件

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>fastjson_source</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.maven.ide.eclipse.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.maven.ide.eclipse.maven2Nature</nature>
    </natures>
</projectDescription>

.classpath 文件

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
    <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
    <classpathentry kind="lib" path=".project"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
 

相关推荐