spring boot hotswap with Intellij IDE

后端 未结 7 2081
长发绾君心
长发绾君心 2020-11-28 02:40

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

相关标签:
7条回答
  • 2020-11-28 03:01

    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 Windows
    • Cmd+Shift+F9 on Mac
    0 讨论(0)
  • 2020-11-28 03:01

    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!!!

    Watch Solution On YouTube

    0 讨论(0)
  • 2020-11-28 03:06

    You can use either of the following methods to auto reload Thymeleaf templates:

    1. Spring Boot Dev Tools
    2. Change Thymeleaf Templates Path
    3. Gulp Watch

    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.

    0 讨论(0)
  • 2020-11-28 03:10

    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:

    1. Go to the project run configuration.

    2. Set on'Update' action and 'On frame deactivation' both to 'Update classes and resources'. And it worked like a charm.

    0 讨论(0)
  • 2020-11-28 03:16

    A solution that uses devTools works :

    1 - Adding devtools to your project

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    

    2- Enabling automatic build

    Open the Settings --> Build-Execution-Deployment --> Compiler and enable :

    Build Project Automatically.
    

    3- Update the value of compiler.automake.allow.when.app.running

    press ctrl+shift+A and search for the registry. In the registry, enable :

    compiler.automake.allow.when.app.running
    

    Hope it helps !


    References :

    • https://dzone.com/articles/spring-boot-application-live-reload-hot-swap-with
    0 讨论(0)
  • 2020-11-28 03:17

    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.

    0 讨论(0)
提交回复
热议问题