I have a spring boot application running fine with Intellij IDE. i.e i started the Application class that has the main method which delegates to SpringApplication.run. Everything works great except hotswap. When I change the source, I am forced to re-start the application. Even If I start the application in debug mode, I dont see hotswap working. I could see that Intellij's Debug settings have hotswap enabled.
My observation shows that when I run the springboot application, classpath used is my
/projects/MyProject/classes/production/....
Files under classes/production
are not getting updated when I change the code. Intellij IDE compiles the files but does not update classes/production directory. How do I get hotswap working with IntelliJ IDE for spring-boot?
Reload all files Recompilation happens automatically if the Build project before reloading classes option is enabled in Settings/Preferences | Build, Execution, Deployment | Debugger | HotSwap. If this option is disabled, you need to recompile the files before reloading (Build | Recompile Ctrl+Shift+F9 ).
IntelliJ IDEA creates a Spring Boot run configuration that you can use to run your new Spring application. If the run configuration is selected, press Shift+F10 . icon in the gutter of the SpringBootTutorialApplication. java file next to the class declaration or the main() method declaration.
There are several options for hot reloading. The recommended approach is to use spring-boot-devtools , as it provides additional development-time features, such as support for fast application restarts and LiveReload as well as sensible development-time configuration (such as template caching).
Click the currently running service, and then click Edit Configurations . Click on the program you want to configure, find On 'Update' action and On frame deactivation select Update classes and resources . Click OK to implement hot deployment. After the above configuration, after modifying the code.
A solution that uses devTools works :
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency>
Open the Settings --> Build-Execution-Deployment --> Compiler and enable :
Build Project Automatically.
press ctrl+shift+A
and search for the registry
. In the registry, enable :
compiler.automake.allow.when.app.running
Hope it helps !
References :
Found out the root cause. This has nothing to do with Spring-boot. On changing my groovy source files, files were not auto-compiled.
To recompile changed files and swap them:
Ctrl+Shift+F9
on WindowsCmd+Shift+F9
on MacIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With