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 Mac
문제
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?
해결책 2
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 Mac다른 팁
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
References :
Step 1: Add developer tools denpendency
Maven.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Gradle.
dependencies {
compile("org.springframework.boot:spring-boot-devtools")
}
Step 2: Go to File | Settings | Build, Execution, Deployment | Compiler
enable Build project automatically & Apply & OK
Step 3: Press shortcut key Ctrl+Shift+A & Search Registry keyword & Press Enter
Enable complier.automake.allow.when.app.running & Click Close Button
Step 4: Disable cache on your favorite web browser
Step 5: Done!!!
In my case even after adding the Spring Boot dev tools and checking the build project automatically, it was not working. What was missing was this:
Go to the project run configuration.
Set on'Update' action and 'On frame deactivation' both to 'Update classes and resources'. And it worked like a charm.
Use spring-loaded. It works fine with bean reloading. It's free alternative to JRebel.
Another way is to use DCEVM or hotswapagent
I noticed the same problem as well. I am on the Intellij 13.1.1. and for it to hotswap the changed class. I have to run the app in debug mode, then after changing the class, select "Run->Reload Changed Classes" manually.
I also have the debugger set to hotswap as indicated in http://www.jetbrains.com/idea/webhelp/reloading-classes.html but doesn't seem to work.
Anyway, at least the manual "Run->Reload Changed Classes" menu works.
@Sameer Khanal's answer worked but since so much time has passed, I offer some clarification
Install the spring boot devtools dependencies (https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools)
Update the options for On 'Update' action
and On frame deactivation
like so:
Click on OK and you are done
Hope that helps
For multiple changes, use "Compile And Reload File"(Add "spring-boot-devtools" first). Double click "Shift" to show the diagram in Mac.
Or try spring-loaded which I haven't tried yet. But seems it could work.
Add the deployment artifact exploded, in the deployment tab, this did the trick for me.
You can use either of the following methods to auto reload Thymeleaf templates:
I recommend Gulp watch as it is easier to setup and works great:
var gulp = require('gulp'),
watch = require('gulp-watch');
gulp.task('watch', function () {
return watch('src/main/resources/**/*.*', () => {
gulp.src('src/main/resources/**')
//replace with build/resources/main/ for netBeans
.pipe(gulp.dest('out/production/resources/'));
});
});
gulp.task('default', ['watch']);
Now enter the following command in your terminal to start gulp watch:
$ gulp
//OR
$ gulp watch
I wrote a blog post on auto reloading Thymeleaf templates without restart in IntelliJ IDE.