IntelliJ外部库依赖于包 [英] IntelliJ external library dependence within packages

查看:181
本文介绍了IntelliJ外部库依赖于包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IntelliJ项目中,我已经建立了对外部库的依赖(项目结构 - >模块 - >依赖项 - >添加 - >库)。该库出现在左侧的外部库选项卡中。

Within an IntelliJ project, I have set up a dependence on an external library (project structure -> Modules -> Dependencies -> Add -> Library). This library appears in the "External Libraries" tab on the left.

对于直接放在src目录中的类,这可以正常工作。

For classes which are placed directly in the src directory this works fine.

但是,对于我在项目中创建的软件包,IntelliJ无法识别外部库中的函数(我得到一条红线和无法解析符号)。

However, for packages I create within the project, IntelliJ doesn't recognize functions from the external library (I get a red line and a "cannot resolve symbol").

我应该如何设置外部库以解决此问题?

How should I set up the external library so that this issue is resolved?

推荐答案


  1. 打开项目结构对话框(例如Ctrl + Shift + Alt + S)。

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).

In在对话框的左侧窗格中,选择模块。

In the left-hand pane of the dialog, select Modules.

在右侧窗格中,选择感兴趣的模块。

In the pane to the right, select the module of interest.

在对话框的右侧,在Module页面上,选择Dependencies选项卡。

In the right-hand part of the dialog, on the Module page, select the Dependencies tab.

On在Dependencies选项卡中,单击添加并选择Jars或目录。

On the Dependencies tab, click add and select Jars or directories.

在打开的对话框中,选择所需的文件和文件夹。这些可能是单独的.class,.java,.jar和.zip文件,以及包含此类文件的目录。单击确定。

In the dialog that opens, select the necessary files and folders. These may be individual .class, .java, .jar and .zip files, and the directories containing such files. Click OK.

如有必要,请选择导出选项并更改依赖关系范围。

If necessary, select the Export option and change the dependency scope.

8.在项目结构对话框中单击确定。

8.Click OK in the Project Structure dialog.

来源

这篇关于IntelliJ外部库依赖于包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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