Hot reload beta
INFO
Hot reload is complex to implement and requires many compatibility scenarios. If this project helps you save development time, you might as well click . Your recognition will make more people discover it, and your support is my motivation to update. If it doesn't work, please submit
for feedback.
When writing code traditionally, you need to restart the application to take effect, while hot reload can make the written code take effect immediately without restarting the application, so that the code changes written by the developer can take effect instantly, greatly improving the iteration efficiency. Supports changes to properties and methods of classes (including proxy classes), Spring, Mybatis and other mainstream frameworks. At the same time, it is compatible with multiple JDK versions such as jdk8, jdk11, jdk17, jdk21, etc.
1. Enable hot reload
Click and the icon will change to
, indicating that hot reload is enabled. Start the project hot reload in the big airplane mode to take effect.
- Off state
- On state
TIP
Hot reload requires a specific JDK to take effect. Please refer to JDK installation to complete JDK initialization
If the startup project prompts
DCEVM is not installed
, check whether the JDK installation is correct. JDK8 Check whether the commandjava -XXaltjvm=dcevm -version
can be output normally.
2. Trigger hot reload
Start the application in the state of the big plane, the project outputs the following log, and prints the loaded hot reload plug-in.
DebugTools: 2025-01-07 16:41:07.909 INFO [main] i.g.f.d.t.h.c.HotswapAgent 44 : open hot reload unlimited runtime class redefinition.{3.3.0}
DebugTools: 2025-01-07 16:41:08.498 INFO [main] i.g.f.d.t.h.c.c.PluginRegistry 132: Discovered plugins: [JdkPlugin, ClassInitPlugin, AnonymousClassPatch, WatchResources, HotSwapper, Proxy, Spring, MyBatis]
2.1 Compile project
After the application is started, hot reload can be triggered by compiling and building
2.2 Debug hot update
If the application is started by Debug
, hot reload can be triggered by the following method, and breakpoint information can also be updated.
- Use the
Compile and Reload Modified Files
button in the right-click menu.
- Use the
Code changed
button on the main file page.
2.3 Hot deployment
Click the button to wake up the main page.
After selecting the file to be deployed
Compiler Type
: file compilation methodLocal Intellij Idea
: compile the changed files through the idea compilerRemote Attach Application
: remote dynamic compilation of the changed files through the attached application
Select Type
: file selection methodJava
: changed java filesResources
: changed resource files (pending)Vcs
: select to obtain file changes through the vcs tool, and do not select to obtain file changes through the file modification time
Click the OK
button and wait for the compilation to complete. After the compilation is completed, a prompt for successful compilation will pop up.
TIP
- Hot reloading of changed files through hot deployment is supported only after the application is attached
- When using remote dynamic compilation, the attached application must be started through JDK, not JRE.
TIP
During hot deployment, idea may sometimes fail to obtain the latest breakpoint information. If you need to update the breakpoint in time, please use method 2
2.4 Single file remote compilation
The Remote Compile 'xxx' to Hot Reload
button in the right-click menu can be used to hot reload a single changed file through remote dynamic compilation.
After hot deployment is completed, a prompt will pop up indicating successful compilation.
TIP
- Hot reloading of changed files through hot deployment is only supported after the application is attached
- When using remote dynamic compilation, the attached application must be started through JDK, not JRE.
TIP
During hot deployment, idea may sometimes fail to obtain the latest breakpoint information. If you need to update the breakpoint in time, please use Method 2
2.5 Single XML file
The changed xml
file can also trigger hot reload separately through the Compile 'xxx.xml' to Target
method in the right-click menu.
TIP
- The implementation method is to move the xml file from
src/main/resources
to the correspondingtarget/
. - You can also trigger the xml file through Method 1.
3. In which cases can hot reload be performed
3.1 Ordinary class files
- Add new class files
- Add/modify properties/methods/inner classes in existing classes.
- Anonymous inner class
- Enumeration class
Click class file hot reload for details
3.2 Proxy class
- Java JDK proxy class.
- Cglib proxy class.
Click proxy class hot reload for details
3.3 SpringBoot Bean
- Controller
- Service
- Component
- Repository
Click SpringBoot for details
3.4 MyBatis
Mapper (new/modified)
Xml (new/modified)
Note
MyBatis currently supports Spring
environment, other situations are unknown.
Click MyBatis for details
3.5 MyBatisPlus
Entity (new/modified)
Mapper (new/modified)
Xml (new/modified)
TIP
MyBatisPlus currently supports Spring
environment, other situations are unknown.
Click MyBatisPlus for details
3.6 Others
Hot reload can also be used in other situations. I won’t give examples here. If it doesn’t work, please submit an issue to give feedback.