调用来自不同项目的导入抽象类或接口的方法时出现 Eclipse 错误
我刚刚从源代码管理下载了一个大型项目,其中包括多个项目 - 正如我之前所做的那样,没有出现任何问题。通常类依赖关系已经定义,我可以毫无困难地将包导入到 eclipse 中。
这次我似乎在项目之间的沟通上遇到了困难。我所有的错误似乎都是由于类扩展/实现抽象类或接口造成的。如果一个项目中的类 A 扩展或实现了另一个项目中的另一个类或接口,那么当类 A 尝试调用或重写继承的方法时,我最终会收到异常。我检查了构建路径,它似乎是正确的,并且我能够导入抽象类和接口,只是不使用其中的方法。仅当正在实现的接口或类存在于与实现它的类不同的包中时,才会出现问题。
我尝试过刷新包、清理和重建,以及从 ant 脚本进行重建,但这些更改似乎都没有帮助。谁能建议可能出了什么问题?
顺便说一句,当我从源代码管理中检查所有内容时,我想我可能已经获得了一些错误签入的 Eclipse 元数据;这可以解释 eclipse 如何陷入不一致的状态。
谢谢!
I've just downloaded a large project from source control which includes multuple projects-as I've done before without trouble. Usually the class depencies are already defined and I can import the packages into eclipse without difficulty.
This time I seem to have difficulty with communication between projects. All my errors seem to be due to classes extending/implementing abstract classes or interfaces. If class A in one project extends or implements another class or interface from another project I end up getting exceptions when class A tries to call or override inherited methods. I've checked the build path and it seems correct, and I'm able to import the abstract class and interfaces, just not use methods from them. The issues only occur when the interface or class being implemented exists in a different package then the class implementing it.
I've tried refreshing the packages, cleaning and rebuilding, and doing a rebuild from the ant scripts, none of these changes seemed to help. Can anyone suggest what may be wrong?
Incidentally when I checked out everything from source control I think I may have gotten some of the eclipse metadata which had been checked in by mistake; which may explain how eclipse got in an inconsistent state.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您编译正常,但在运行时收到
ClassNotFoundExceptions
,则需要确保运行配置的“类路径”选项卡中可见的内容与项目的构建路径相匹配。这将确保您使用与构建时相同的类路径运行。
If you are compiling fine but getting
ClassNotFoundExceptions
at runtime, you need to make sure what's visible in the Classpath tab of your Run Configurations matches your Project's build path.This will ensure you are running with the same classpath you are building with.