昨天我从Eclipse切换到IntelliJ IDEA。

我也在WebSphere Server 7中使用JRebel。

现在一切似乎都运行得很好,除了当我修改一个Java文件并点击保存时,IntelliJ不会重新编译文件,以便JRebel拾取它。

Eclipse的“自动构建”特性解决了这个问题。

在IntelliJ IDEA中,我必须按CTRL+SHIFT+9来重新编译JRebel的相关类。如果跨两个文件进行更改,我必须在每个文件上都这样做,因为IntelliJ使用了保存所有机制,很难知道手动重新编译什么,我也不感兴趣。

难道没有办法让IntelliJ自己来做这个吗?


当前回答

我也有同样的问题。我认为检查你的类是否可以编译是合适的。单击recompile(默认为Ctrl+Shift+F9)。如果它不工作,那么你必须调查为什么它不能编译。

在我的例子中,代码没有自动编译,因为编译过程中存在隐藏的错误(它们没有在任何地方的日志中显示,而且maven clean-install正在工作)。根本原因是错误的项目结构->模块配置,因此Intellij Idea无法根据此配置构建它。

其他回答

对于那些使用新的Intellij版本却找不到compiler. autommake .allow.when.app.running的人

https://youtrack.jetbrains.com/issue/IDEA-274903

基本上选项现在已经移动到设置->高级设置->编译器(检查允许自动生成选项)

警告

Eclipse模式插件已经过时,并且与最近的IDEA 12+版本不兼容。如果你安装它,IDE将挂起每一个文件更改,并将响应极慢。


IntelliJ IDEA不使用自动构建,它在运行中检测错误,而不是通过编译器。类似于Eclipse模式将在IDEA 12中可用:

使用Build | Make,它调用增量的Make过程,只编译更改的和依赖的文件(它非常快)。

还有一个常见问题解答条目可能会有所帮助。

Update on the automatic make feature: When run/debug configuration is running, Make project automatically has no effect. Classes on disk will change only on Build | Make. It's the core design decision as in our opinion class changes on disk should be always under user's control. Automatic make is not the copycat of Eclipse feature, it works differently and it's main purpose is to save time waiting for the classes to be ready when they are really needed (before running the app or tests). Automatic make doesn't replace the explicit compilation that you still need to trigger like in the case described in this question. If you are looking for different behavior, EclipseMode plug-in linked in the FAQ above would be a better choice.

它不适合我,因为在我的项目结构中有一个不必要的模块。我想测试是用另一个模块执行的。

我不知道它是怎么变成这样的,但去掉它就解决了问题。

确保运行/调试设置使用的是使用自动保存构建的模块。

例:参见

您可以在“项目结构-模块”中更改模块

我最终录制了一个宏来保存并在一步中编译,并按Ctrl+s键映射到它。

我有同样的问题,也有一个问题文件图标在intellij,所以我删除了。idea文件夹和重新导入项目解决了我的问题。