What kind of changes require which restart procedure?
Answered
Given a Java Maven project with nested modules. When changing the source code of one of the nested modules, various options to restart the application exist:
Restart App:
- Simply hitting “Rerun App Ctrl+F5” or this button
(my observation is, that this already includes changes from commenting / uncommenting a line)
Maven rebuild
- Stop the app, run “Maven Clean & Install” of only the nested module
and restarting the app - Stop the app, run “Maven Clean & Install” of the top level parent module and restart the app
Hot Swap
- Hit Ctrl-Shift-F9 in the editor on the changed source code without any restarting
- Hit Ctrl-Shift-F9 in the editor on the changed source code and restart the app with Ctrl-F5
What are the criteria for when which procedure can be used to make changes effective? This is obviously to find the fastest way possible to include changes to keep development cycle short.
Please sign in to leave a comment.
Hi,
Try to enable the
File | Settings | Tools | Actions on Save | Build project(which is same asSettings | Build, Execution, Deployment | Compiler | Build project automatically) andFile | Settings | Advanced Settings | Allow auto-make to start even if developed application is currently running.Now the IDEA will auto-update the project in your case, however it seems you still need to run it in debug mode and press the menu/action Build | Build Project.
For some big class file changes,as so far know there is something like JRebel(paid software) or open-sourced https://github.com/HotswapProjects/HotswapAgent plus JBR https://github.com/JetBrains/JetBrainsRuntime/releases, it needs some configuration to add JVM params like -XX:+AllowEnhancedClassRedefinition -XX:HotswapAgent=fatjar.
@Jacky Liu Thanks for your answer. Do you have any authoritative reference (ideally from IDEA documentation) where the various options are described regarding how to restart a running application?
Hello, might this be helpful:
https://www.jetbrains.com/help/idea/2023.3/spring-boot.html#enable-auto-restart
https://www.jetbrains.com/help/idea/2023.3/delegate-build-and-run-actions-to-maven.html#delegate_to_maven
When using build system with IDEA, usually it's faster to build(don't select Delegate IDE build/run actions to maven.)
Still I'm not quite clear what's your question is. Usually Hot Swap will be the faster way, and using IDEA build system is faster than Maven one. If your project only can be run with Maven build, then mvnd should be some help: https://github.com/apache/maven-mvnd