简体   繁体   English

在包下的类中看不到外部Jar

[英]External Jar is not visible from classes under a package

I have an external.jar in my maven project running with IntelliJ. 我在使用IntelliJ运行的Maven项目中有一个external.jar My class1 cannot resolve my external.jar until I remove it out from package1 . 我的class1无法解析我的external.jar直到将其从package1删除。 Could you please suggest me a best practice in order to solve such a problem by keeping the folder structure as below. 您能否建议我一个最佳实践,以通过保持以下文件夹结构来解决此类问题。

mvn -v : Apache Maven 3.6.0, Java version: 1.8.0_212
Folder Structure:
-src
--test

---java
----package1
-----class1
----package2

---resources
----external.jar

-target
-External Libraries

Steps for adding external jars in IntelliJ IDEA as follows. 在IntelliJ IDEA中添加外部jars步骤如下。

  1. Click File from the toolbar 从工具栏中单击文件
  2. Project Structure ( CTRL + SHIFT + ALT + S on Windows/Linux, + ; on Mac OS X) 项目结构(在Windows / Linux上为CTRL + SHIFT + ALT + S ,在Mac OS X上为 +
  3. Select Modules on the left panel 在左侧面板上选择模块
  4. Dependencies tab 依赖项选项卡
  5. + → JARs or directories + →JAR或目录
  6. Select a library you want to add and click Add Selected at the bottom of the dialog 选择要添加的库,然后单击对话框底部的“添加所选内容”

Please refer this official document from IntelliJ. 请从IntelliJ参考官方文档。

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

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