报错:this compilation unit is not on the build path of a Java project

this compilation unit is not on the build path of a Java project


从SVN上面检出了一个项目,在写代码的时候使用自动提示就报“this compilation unit is not on the build path of a Java project”错误,如图。

 

查看Build Path 时也没有信息

 

原因是检出的项目缺失了Java编译器。
解决方案如下:

关闭eclipse
找到项目文件夹内的.project文件
在文件内增加Java编译器相关内容:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>检出的项目名称</name>
    <comment></comment>
    <projects>
    </projects>
    <!-- 检查有没有javabuilder,没有的话添加-->
    <buildSpec>    
        <buildCommand>    
            <name>org.eclipse.jdt.core.javabuilder</name>    
            <arguments>    
            </arguments>    
        </buildCommand>    
    </buildSpec>   
    <natures>
    <!-- 检查有没有javanature,没有的话添加-->
        <nature>org.eclipse.jdt.core.javanature</nature>    
        <nature>org.apache.ivyde.eclipse.ivynature</nature>    
    </natures>    
</projectDescription>

原项目project文件:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>demo</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.m2e.core.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
	</natures>
</projectDescription>

修改后文件:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>demo</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.m2e.core.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>

	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
	</natures>
</projectDescription>


4.重开编译器项目即可重新编译为正常项目
 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值