Skip to content

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. Hot reload makes code changes take effect immediately without restarting the application, greatly improving iteration efficiency. It supports changes to class properties and methods (including proxy classes), Spring, Solon, MyBatis, and other mainstream frameworks. It is compatible with JDK 8, JDK 11, JDK 17, JDK 21, JDK 25, and other versions.

1. Enable hot reload

  • Please disable the Build, Execution, Deployment -> Debugger -> Async Stack Traces configuration in IDEA.

instrumenting_agent.png

  • Click Hotswap 'xxx' with DebugTools in More Actions to start the application with a hot reload.

start_hotswap.png

If you find it cumbersome to open More Actions every time, you can place the button in the Main Toolbar

For example, add a button on the right side as shown below:

main_toolbar.png

Search for Hotswap with DebugTools. If you want to change the icon, you can also modify it below.

add_hotswap_action.png

This will allow you to click from outside the application.

start_hotswap_toolbar.png

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 command java -XXaltjvm=dcevm -version can be output normally. dcevm_not_install.png

2. Trigger hot reload

Start the application in debug mode. The project outputs the following log and prints the loaded hot reload plug-in.

text
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, Solon, Mybatis]

2.1 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.

compile_reload_file.png

  • Use the Code changed button on the main file page.

compile_code_changed.png

2.2 Hot deployment

Hot deployment can send changes to remote applications, and it can also deploy local changes to an already attached target application.

For detailed configuration and operation steps, see Hot Deploy.

2.3 Single file remote compilation

Open the context menu in a Java source file editor or project tree, then click Remote Compile "xxx.java" to Hot Deploy. The plugin saves the current file, sends the source code to the attached target application, and the target application compiles and hot deploys it.

If the current project is connected to multiple applications, the plugin asks you to choose the target connection first. The request uses the ClassLoader currently selected on that connection card.

hot_deploy_remote_compile_context_menu.png

After hot deployment completes, the result is printed in IDEA's Run tool window. The tab title is Remote Deploy Result; when multiple applications are connected, the title also includes the application name.

hot_deploy_remote_compile_result.png

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 1

2.4 Single XML file

Open the context menu in an XML file editor or project tree, then click Compile "xxx.xml" to target directory. The plugin saves the current XML file and writes it to the current module's compilation output directory by its relative path from the source root.

hot_reload_xml_context_menu.png

TIP

  • This operation only overwrites the resource file in the compilation output directory. It does not modify the XML file in the source directory.
  • The XML file must be under a project source root or resource root. Otherwise, the plugin cannot calculate the relative path to write into target/classes.
  • You can also trigger XML updates by recompiling the project 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

Pay special attention to changes in static information

Hot reloading of static fields will cause the values initialized at compile time to overwrite the values at runtime. See click 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 dynamic-datasource

  • @DS annotation added
  • @DS annotation modified

Click DynamicDatasource for details

3.7 HuTool

Support hutool hot reload

  • ReflectUtil reflection tool class
  • BeanDesc bean descriptor
  • JSONUtil json tool class

3.8 Gson

Support Gson toolkit hot reload

3.9 EasyExcel

Support EasyExcel hot reload

3.10 Jackson

Support Jackson hot reload

3.11 FastJson、FastJson2

Support FastJsonFastJson2 hot reload

3.12 hibernate-validator

Support hibernate-validator hot reload

3.13 Solon

Support Solon class and container hot reload

  • Controller
  • Component
  • Configuration
  • ...

Click Solon for details

3.14 OpenFeign

Supports hot reload of OpenFeign

  • Supports adding/modifying interfaces annotated with @FeignClient

3.15 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.

4. Disable Hot Reload Plugins

If a hot reload plugin has compatibility issues in the current project, temporarily disable the specified plugin in Settings | DebugTools | Hot Reload, then restart the application with hot reload.

hot_reload_disable_plugins.png

Disabled Plugins writes the selected plugin names into the hot reload startup parameter disabledPlugins. During Agent initialization, plugins with matching names are skipped. This is useful for temporarily avoiding startup exceptions, class transformation exceptions, or hot reload side effects caused by a specific framework plugin.

Available plugins are grouped by type:

GroupPlugins
BaseJdkPlugin, Class, Proxy, HotSwapper, WatchResources
Third PartySpring, Feign, MyBatis, Solon
OtherIntelliJIdea, HibernateValidator, EasyExcel, Gson, FastJson, HuTool

WARNING

  • This configuration only affects applications started with hot reload after the setting changes. Already running applications do not unload plugins immediately.
  • Disabling a plugin also disables the corresponding capability. For example, after disabling Spring, hot reload capabilities related to adding or modifying Spring Beans stop working.
  • If you are only troubleshooting, disable one plugin at a time, confirm the impact, then decide whether to keep it disabled.