Eclipse错误消息declared package not match expected package-packa

我从github下载了一个开源项目后,导入到自己Eclipse之后,遇到了这个烦人的错误消息:

The declared package "com.sap.smartService" does not match the expected package "main.java.com.sap.smartService"

Eclipse错误消息declared package not match expected package

这是我的项目文件目录:

Eclipse错误消息declared package not match expected package

解决方案:对项目点击右键,选择Properties->Build Path, 发现src文件夹被设为build path。

Eclipse错误消息declared package not match expected package

首先右键src文件夹,选择Remove from Build Path将其从build path中移除:

Eclipse错误消息declared package not match expected package

然后选择src/main下面的java文件夹,设置成build path,重启Eclipse:

Eclipse错误消息declared package not match expected package

错误即消失:

Eclipse错误消息declared package not match expected package

推荐阅读