如何启用 Intellij 热代码交换
Intellij 似乎没有在我的安装上进行基本的热代码交换。
对于这段代码:
public class MainTest {
public void method1() {
System.out.println("Breakpoint here");
}
public void method2() {
System.out.println("Line that will get 24 modified");
}
public static void main(String[] args) {
System.out.println("First print here");
MainTest mainTest = new MainTest();
mainTest.method1();
mainTest.method2();
System.out.println("Line that I do not modify");
}
}
我在 mainTest.method1();
上放置了一个断点,然后修改 method2() 处的字符串,点击 ctrl+s 并继续一步一步进行。不幸的是,运行时未更新,正在打印旧字符串。句号 - 编译 - 运行确实打印新字符串。所以我的结论是热插拔不起作用。
我需要设置任何设置才能启用热代码交换吗?
- Ubuntu、JDK 1.6
- Intellij 10.5 Ultimate(评估)
Intellij does not seem to be doing basic hot code swap on my installation.
For this code:
public class MainTest {
public void method1() {
System.out.println("Breakpoint here");
}
public void method2() {
System.out.println("Line that will get 24 modified");
}
public static void main(String[] args) {
System.out.println("First print here");
MainTest mainTest = new MainTest();
mainTest.method1();
mainTest.method2();
System.out.println("Line that I do not modify");
}
}
I put a breakpoint on mainTest.method1();
then modify the string at method2(), hit ctrl+s and continue to step by step. Unfortunately the runtime is not updated, old string is being printed. Full stop - compile - run does print the new string. So my conclusion is hot-swap not working.
Is there any settings I need to set to enable hot code swap?
- Ubuntu, JDK 1.6
- Intellij 10.5 Ultimate (evaluation)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
在等待断点时保存类后,只需使用
Build -> 重新编译类即可。编译“MainTest.java”
或使用标准键绑定按Ctrl+Shift+F9
。然后,IntelliJ IDEA 将显示一个小对话框,询问您是否要重新加载该类。
After saving your class while waiting on your breakpoint just recompile your class with
Build -> Compile 'MainTest.java'
or pressCtrl+Shift+F9
with the standard key bindings.IntelliJ IDEA will then show a small dialog in which it asks you if you want to reload that class.
经过以下修改并启用热插拔后,Java 文件中的更改需要 1-2 秒的重新启动时间。 (对于我来说,初始启动时间约为 7 秒)。
我希望下面的方法可以帮助...
首先,您需要在首选项菜单中选中“自动创建项目”。
打开首选项菜单;
您可以转到顶部菜单并单击;
或您可以通过键盘输入以下快捷方式;
然后,您可以勾选
自动生成项目
,如下图所示;其次,您需要将
compiler.automake.allow.when.app.running
注册表设置修改为true。要打开注册表,您需要单击下面的键盘快捷键:
输入
registry
,如下图所示,选择Registry
,然后按键盘回车键;打开
Registry
窗口后,输入compiler.automake
以查看compiler.automake.allow.when.app.running
选项,并将其检查为在下图中;然后,您需要重新启动 IntelliJ 以使注册表更改生效。
After below modifications and enabling hot swap, a change in a Java file took 1-2 seconds of restart time. (Initial start time is around 7 seconds for me).
I hope below method helps...
First, you need to check “Make project automatically” in preferences menu.
To open preferences menu;
you can go to top menu and click;
or you can type below shortcut via keyboard;
Then, you can check
Make project automatically
as in below picture;Secondly, you need to modify
compiler.automake.allow.when.app.running
registry setting as true.To open registry, you need to click below keyboard shortcut:
Type
registry
as in below picture, selectRegistry
, and hit enter button of keyboard;After
Registry
window opened, typecompiler.automake
to seecompiler.automake.allow.when.app.running
option, and check it as in below picture;Then, you need to restart IntelliJ to make registry changes work.
进入设置-->选择调试-->热交换
Go to Setting --> Select Debug --> HotSwap
有一个
调试器> intellij 11 中的 HotSwap 选项。
There is a
Debugger > HotSwap
option in intellij 11.我希望每次保存 Java 文件时热交换都能自动运行。其他答案都没有这样做,所以我只是:
Action: Hotswap
(Run -> Reload Changed Classes
)I wanted hotswap to automatically run every time I saved a Java file. None of the other answers did this so I just:
Action: Hotswap
at the end of the macro (Run -> Reload Changed Classes
)我想你是在问这个,
I think you are asking about this,
对于遇到与我相同问题的人,您可能遇到了以下影响 2020.2 更新的最新错误:https://youtrack.jetbrains.com/issue/IDEA-247530?_ga=2.116305920.729836936.1599654650-984156210.1599654650
TL;DR 作为解决方法,您需要重新激活Groovy 插件。
For anyone experiencing the same problem as me, you might have incurred in the following recent bug affecting the 2020.2 update: https://youtrack.jetbrains.com/issue/IDEA-247530?_ga=2.116305920.729836936.1599654650-984156210.1599654650
TL;DR As a workaround, you need to re-activate the Groovy plugin.
我在Ubuntu上遇到了这个问题。我还遇到了一个明显不相关的问题,IntelliJ 给出了有关文件监视限制的错误(抱歉,我不再有确切的错误消息)。为了解决后面的问题,我执行了以下步骤:
将以下行添加到
/etc/sysctl.conf
文件或新的 *.conf 文件(例如idea.conf< /code>)在
/etc/sysctl.d/
目录下:<前><代码>fs.inotify.max_user_watches = 524288
然后运行此命令来应用更改:
sudo sysctl -p --system
现在我的 React 组件重建和热插拔就好了。
来源
I encountered this problem on Ubuntu. I also had an apparently unrelated issue where IntelliJ gave an error about the file watch limit (my apologies that I no longer have the exact error message). To solve this later issue I did the following steps:
Add the following line to either
/etc/sysctl.conf
file or a new *.conf file (e.g.idea.conf
) under/etc/sysctl.d/
directory:Then run this command to apply the change:
sudo sysctl -p --system
Now my React components rebuild and hot swap just fine.
Source