欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何处理Eclipse错误消息 The declared package does not match the expected package EclipseJavapackage 

程序员文章站 2022-05-20 18:27:56
...

我从github下载了一个开源项目后,导入到自己Eclipse之后,遇到了这个烦人的错误消息:
The declared package "com.sap.smartService" does not match the expected package "main.java.com.sap.smartService"

 

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage 

这是我的项目文件目录:

 

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage 

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

 

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage 

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

 

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage 

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

 

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage 

错误即消失:

 

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage 

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

 
如何处理Eclipse错误消息 The declared package does not match the expected package
            
    
    
        EclipseJavapackage