如何将外部JAR从一个项目导入到另一个项目?

时间:2018-06-26 07:58:36

标签: intellij-idea

我创建了一个新的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.

1 个答案:

答案 0 :(得分:1)

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