What kind of changes require which restart procedure?

已回答

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:

  1. Simply hitting “Rerun App Ctrl+F5” or this button (my observation is, that this already includes changes from commenting / uncommenting a line)

 

Maven rebuild

  1. Stop the app, run “Maven Clean & Install” of only the nested module and restarting the app
  2. Stop the app, run “Maven Clean & Install” of the top level parent module and restart the app

 

Hot Swap

  1. Hit Ctrl-Shift-F9 in the editor on the changed source code without any restarting
  2. 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.

0

Hi,

Try to enable the File | Settings | Tools | Actions on Save | Build project (which is same as Settings | Build, Execution, Deployment | Compiler | Build project automatically) and File | 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.

 

0

@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?

0

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

 

0

请先登录再写评论。