繁体   English   中英

导入com.example无法解析

[英]The import com.example cannot be resolved

我正在尝试编译Google在协议缓冲区上给出的这个示例: https//developers.google.com/protocol-buffers/docs/javatutorial

它附带了一个ListPeople.java和AddPerson.java文件以及一堆导入。 问题是我得到“导入com.example无法解析”,如此截图中所示:

http://postimg.org/image/67whg6a57/full/

This is the full path of the import com.example java file:
http://postimg.org/image/wexoc4sez/full/

and where all of my files are located:
http://postimg.org/image/4veseacpn/full/

我试过做以下事情:

Project->Clean
File->Refresh
Property->Java build path->add external JAR:
http://postimg.org/image/xjrqhievv/full/

这些都没有用。 问题是什么?

所以这似乎是您的项目中缺少的代码。 如果您按Shift-Ctrl-T并键入AddressBook,它是否存在?

如果它不存在,那么它尚未从示例.proto文件中生成,如Google on the protocol buffers文件所指定的那样

您正在尝试添加Java 文件,就像它们是库一样 - 它们不是。

添加“src”目录作为源路径(Java Build Path设置中最左侧的选项卡)。 或者,如果它已经是源路径,请尝试在包资源管理器中刷新它。 无论哪种方式,你绝对不希望将源文件作为库...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM