IntelliJ IDE | .iml文件丢失或删除 [英] IntelliJ IDE | .iml File lost or deleted

查看:5971
本文介绍了IntelliJ IDE | .iml文件丢失或删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上周我正在使用IntelliJ IDE开发Java EE项目。



今天:当我启动IntelliJ 2016.1时,它给了我错误:



加载项目时出错



无法加载模块FirstWebApp



当我查看详细信息时,它说它无法找到我的FirstWebApp.iml文件,因此无法加载我的项目。



我在资源管理器中检查了我的项目结构,除了iml文件之外的所有内容都在那里。我也查看了回收站,但我也找不到它。




  • 这样的文件怎么会消失?


  • 如果可能,我怎样才能获取我的iml文件?


  • 这些iml文件有什么作用?




<我是Java世界的新手。如果需要更多信息,请发表评论! :)

解决方案

* .iml文件与您的代码/ Java无关。它是由Intellij在项目的根文件夹中创建的隐藏文件,其中包含您的模块信息。这就是你不应该对这种文件进行版本化的原因,毕竟使用不同IDE的其他开发人员也不需要它们。



如果你关闭了Intellij,我认为还有这是一种获取相同文件的方法,但另一方面,重新生成新的.iml文件非常简单:



基于Gradle的项目



点击使用Gradle文件同步项目按钮(这一个和 BeC 的评论。



使用Intellij社区2018.1进行此次更新:



基于Maven的项目



程序保持不变,我看到的唯一区别是添加图标不再是绿色。也可以尝试删除 rootFolder / .idea / modules.xml ,然后添加模块以重置有关先前配置的所有信息。



基于Gradle的项目



应在Gradle工具窗口中使用刷新所有Gradle项目(查看>工具窗口> Gradle),由标准刷新图标表示。


Last week I was working on a Java EE project with IntelliJ IDE.

Today: As I started up my IntelliJ 2016.1 it gave me the error:

Error Loading Project

Cannot load module FirstWebApp

As I looked at the details it said it couldnot find my FirstWebApp.iml file and so could not load my project.

I checked out my project structure in the Explorer and everything except the iml file were there. I also looked at the Recycle Bin but I couldn't find it there aswell.

  • How can such a file just disapear?

  • How can I get my iml file back if its possible?

  • What do these iml files do?

I'm new in the Java World. If more information is needed just comment! :)

解决方案

*.iml files have nothing to do with your code/Java. It is a hidden file created by Intellij on the root folder of your project which contains your module information. This is the reason you should not version this kind of file, afterall other developers using a different IDE won't need them.

If you closed Intellij, I think there isn't a way to get the same file back, but on the other hand it is pretty simple to regenerate a new .iml file:

Gradle based project

Click the Sync Project with Gradle Files button (this one ) in the toolbar;

Maven based project

Go to File > Project Structures > Modules > Add (click the green + button).

Edit:

My previous answer were based on IntelliJ 14 and it seems some things have changed on the newer versions, as pointed by hBrent and BeC on the comments.

Using Intellij Community 2018.1 for this update:

Maven based project

The procedure remains the same, the only difference I saw is the Add icon isn't green anymore. One can also try removing the rootFolder/.idea/modules.xml and adding the modules afterwards to reset all information regarding the previous configurations.

Gradle based project

Should use "Refresh all Gradle projects" on the Gradle Tool Window (View > Tool Windows > Gradle), represented by the standard refresh icon.

这篇关于IntelliJ IDE | .iml文件丢失或删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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