IntelliJ无法正确导入Jars [英] IntelliJ Doesn't Properly Import Jars

查看:117
本文介绍了IntelliJ无法正确导入Jars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IntelliJ 11.1.3,并且我试图以jar文件的形式附加两个外部库以在模块中使用。我已将它们添加到项目结构 - >模块 - >依赖项中,它们也在库下正确显示,但我无法在源代码中导入它们。

I'm using IntelliJ 11.1.3 and I'm trying to attach two external libraries in the form of jarfiles to use in a module. I've added them in project structure -> module -> dependencies and they show up correctly under libraries as well, but I can't import them in my source code.

我在这里缺少一步吗?我是IntelliJ的新手,以前只使用过Netbeans,所以我有点迷茫。我认为附加外部库并立即使用类很简单,但是当我输入'import'时,我甚至没有在代码完成时获得库名。

Is there a step I'm missing here? I'm pretty new to IntelliJ, having used Netbeans exclusively before, so I'm a little lost. I thought it would be simple enough to attach the external libraries and use the classes immediately, but I don't even get the library names on code completion when I type 'import'.

推荐答案

你做得对,库是在模块依赖项。验证是否在那里添加了正确的文件。

You are doing it right, libraries are configured in the Module Dependencies. Verify that the correct files were added there.

您应该能够在项目视图中的节点下浏览罐子里面。如果您看不到那里的罐子,那么您的库未正确配置。如果您看到罐子,但看不到它们内部的类,它们可能已损坏,请用有效副本替换它们。

You should be able to browse inside the jars in the Project View under Libraries node. If you can't see the jars there, then your library is not configured properly. If you see the jars, but can't see classes inside of them, they are probably broken, replace them with the valid copies.

同时检查是否添加了库到您尝试导入和使用它们的正确模块的依赖项。验证依赖关系的范围,编译很可能是您需要的。

Also check that the libraries are added to the dependencies of the correct module where you try to import and use them. Verify the scope of the dependency, Compile is most likely what you need.

文件 | 无效缓存可能会有所帮助,以防所有内容看起来都正确,但无效。

File | Invalidate Caches may help in case everything looks correct, but doesn't work.

如果没有任何帮助,请与图书馆共享示例项目说明问题。

If nothing helps, please share a sample project with the libraries to illustrate the issue.

这篇关于IntelliJ无法正确导入Jars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆