问题描述
在将json-lib-2.4-jdk15.jar从在线源添加到项目依赖项后,我似乎无法解决此问题,提供的屏幕截图显示了我正在做的演练。 (是的,我一再尝试无效缓存并重启)
I cannot seem to resolve this issue after adding the json-lib-2.4-jdk15.jar from an online source to the project dependencies, screenshots provided to show walkthrough of what I am doing. (and yes I have repeatedly tried "Invalidate caches and restart")
错误:
这是我的项目结构(cmd +;或文件>项目结构)
This is my Project Structure ("cmd + ;" or "File > Project Structure")
它似乎不适用于设置为编译的范围。请注意,我也将.jar文件添加为库,因为我真的不确定为什么我无法使用它。非常感谢任何帮助,谢谢。
It doesn't seem to work on "Scope" set to Compile either. Note that I added the .jar file as a library too because I'm just really unsure as to why I can't get this to work. Any help is greatly appreciated, thanks.
我在这里看错了什么?
推荐答案
您从。在底部,您可以找到Maven存储库的链接,您可以在其中获取jar文件。
You are trying to use org.json.*
classes which are provided by another library. The library you want to use is this one: JSON-java. At the bottom you can find the link to the Maven repository where you can get the jar file.
最新版本(在此回复时)直接下载链接jar在这里:。
The latest version (at the moment of this reply) direct download link for the jar is here: json-20160810.jar.
将其添加到,你的问题应该解决。
Add it to the module dependencies and your problem should resolve.
下次你看到类似的问题浏览外部的库jar里面IntelliJ IDEA项目的库节点视图,查看它包含哪些类以及哪些包。通过这种方式,您可以知道问题是否是由您添加到依赖项中的错误jar引起的,并且实际上并不包含您要使用的类。
Next time you observe similar issue browse inside the library jar under External Libraries node of IntelliJ IDEA project view and see what classes it contains and under which packages. This way you would know if the issue is caused by the wrong jar you've added to the dependencies and which doesn't actually contain the classes you want to use.
这篇关于添加依赖项和库.jar后无法解析json导入Intellij的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!