首页 > 解决方案 > 如何将外部 JAR 从一个项目导入到另一个项目?

问题描述

我创建了一个新的 IntelliJ 项目,我希望它像在另一个项目中一样具有 JAR 依赖项。

有没有一种方法可以在不使用 POM的情况下将JAR 依赖项从一个 IntelliJ 项目导出/复制粘贴到另一个项目?

谢谢。

可选解决方案:

1. Open <old-project>/.idea/libraries folder and <new-project>/.idea/libraries folder.
2. Make sure to enable the displaying of hidden files (in Win7, go to control-panel--> Folder Options --> View, and select the 'Show hidden files...')
3. Copy all XML files exists in .idea/libraries from the old project to the new one.
4. Make sure that each xml points to the right location of Jar. (In case of relative link)
5. Open the <old-project>.iml and <new-project>.iml, and copy all <orderEntry type="library" name"..."/> elements.
6.  Restart your new project.

标签: intellij-idea

解决方案


我不知道从 IDEA 中执行此操作的方法,但是在您的项目文件夹下,您可以找到一个名为的目录.idea/libraries,其中包含一系列 XML 文件,每个外部依赖项都有一个。您应该能够在项目之间复制这些,从而“共享”依赖项。


推荐阅读