Restarts a running server or command-line application when its beans change during a hot reload on the Dart VM.
A VM hot reload swaps method bodies in place, but it does not run
main again: a new bean, a new @GetMapping or a changed config file
would not take effect, because the context was built from the old
generated code. This class closes such a context and starts the
application again, with the same arguments, from the new generated
code. When only method bodies changed, the context keeps running and
its beans keep their state.
Applications do nothing to get it: the generated runApplication and
runApplicationAsync register their context. The development tool
that reloads the program calls it: after the VM's reloadSources, it
calls the VM service extension extensionName. The dart run tasks of
the Zed extensions do this on save (dart --enable-vm-service ... bin/main.dart, then build_runner build, reloadSources and
extensionName).
It only works in debug runs on the Dart VM. In an AOT or product build and on the web it does nothing, and in Flutter the root widget restarts the context itself when Flutter hot reloads.
To keep a context running whatever changed (the server, its open connections and the beans' state then live until the program restarts), set:
spring.devtools.restart.enabled=false
Spring (Java): the restart of Spring Boot DevTools, which reacts to class files changing on disk instead of a service call.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
reloadAll(
) → Future< int> - Restarts every registered context whose generated code changed and returns how many were restarted.
-
track(
ConfigurableApplicationContext context, SpringApplication application()) → void -
Registers
contextfor restarts on hot reload.
Constants
- extensionName → const String
-
The name of the VM service extension a development tool calls after
reloadSources.