简体   繁体   English

导入后 Eclipse 无法解析为类型

[英]Eclipse cannot resolve to a type after import

Newbie question here...I've wrote an application in eclipse and I've added to a private github repo.新手问题...我已经在 eclipse 中编写了一个应用程序,并且我已经添加到一个私有的 github 存储库中。 I went to import the application to a new workspace so I can work out of my github location and not have to constantly copy/paste.我去将应用程序导入到一个新的工作区,这样我就可以在我的 github 位置之外工作,而不必经常复制/粘贴。 When I import the working application as an existing project into Eclipse, everything I've imported gets hit with a "cannot be resolved" error.当我将工作应用程序作为现有项目导入 Eclipse 时,我导入的所有内容都会遇到“无法解决”错误。

I was wondering if their is something I could do to resolve this?我想知道他们是否可以解决这个问题?

This happens sometimes with Eclipse. Eclipse 有时会发生这种情况。 Try to clean your project(Project -> Clean).尝试清理您的项目(项目 -> 清理)。 If that doesnt work restart Eclipse.如果这不起作用,请重新启动 Eclipse。

Another reason could be that you don't have the necessary jar files for your imports.另一个原因可能是您没有导入所需的 jar 文件。 If this is the case then import the jars(Right Click Project -> Properties -> Java Build Path -> Add External Jars).如果是这种情况,则导入 jars(右键单击 Project -> Properties -> Java Build Path -> Add External Jars)。

如果您使用 gradle 作为构建工具,只需运行 gradle eclipse

When this happens for a single class I used to Ctrl+click on the class (Open Declaration).当单个类发生这种情况时,我过去常常 Ctrl+单击该类(打开声明)。 Cut the contents.剪切内容。 Save it.保存。 Paste the contents back.把内容贴回去。 Save it again.再次保存。

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

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