简体   繁体   English

在Eclipse中导入解决错误

[英]Import Resolve Error in Eclipse

for a little project of mine I want to read a JSON from a Webservice. 对于我的一个小项目,我想从Web服务读取JSON。 For this I want to use GSON. 为此,我想使用GSON。 My Problem is that I cannot import the dependencies into my eclipse-project. 我的问题是我无法将依赖项导入到我的eclipse-project中。 I put the jars into my classpath and they really are in the .classpath-File. 我将罐子放入我的类路径中,它们实际上位于.classpath-File中。 The strange thing is, that the eclipse autocomplete suggests me to import the GSON-FIles, but in the import section the import "com.google" cannot be resolved. 奇怪的是,日食自动完成功能提示我导入GSON-Files,但是在导入部分中,无法解析“ com.google”导入。

It looks like this: Picture of file in eclipse 它看起来像这样: 日食中的文件图片

It also does not only happen with GSON, it seems like nothing from a imported .jar can be resolved. 这不仅发生在GSON上,而且似乎无法解决导入的.jar的任何问题。

I hope one of you guys knows a solution to my problem. 我希望你们中的一个知道我的问题的解决方案。


EDIT 编辑

I figured it out myself, didn't consider the module-info java10 creates. 我自己弄清楚了,没有考虑java10创建的模块信息。 By adding requires gson it worked fine. 通过添加requires gson可以正常工作。

Right click on your project> Properties> java build path> Libraries are you able to see the required jar file if not please add via add external jars. 右键单击您的项目>属性> Java构建路径>库 ,您可以查看所需的jar文件(如果没有),请通过添加外部jar添加。 Do Project > clean 做项目>清洁

  1. Remove existing jar entry from build path. 从构建路径中删除现有的jar条目。
  2. Put the jar gson-2.2.4.jar in some folder, for example E:\\external-jar\\gson-2.2.4.jar 将jar gson-2.2.4.jar放在某个文件夹中,例如E:\\ external-jar \\ gson-2.2.4.jar
  3. Right click on the project and go to build path then click on "Add External Archives..". 右键单击该项目,然后转到构建路径,然后单击“添加外部档案..”。
  4. Select the gson-2.2.4.jar and click open. 选择gson-2.2.4.jar,然后单击“打开”。
  5. The gson-2.2.4.jar will now appear in the referenced libraries. gson-2.2.4.jar现在将出现在引用的库中。

Hope this help! 希望有帮助! Let me know if you still face issues. 让我知道您是否仍然遇到问题。

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

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