3

I am using IntelliJ Ultimate, Spring Boot, and Thymeleaf.

I want to enable auto-reload of HTML without restarting the server and without CTRL-F9.

I have read the following already and I think it should be working, but it's not:

I have done the following steps:

build.gradle snippet

compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.5.2.RELEASE'
compile("org.springframework.boot:spring-boot-devtools")
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

bootRun {
    addResources = true
}

IntelliJ Settings for Compilier:

Intellij Compilier

And Intellij Registry Setting:

Intelij Registry

My HTML is in main\resources\templates and my application.properties is in \resources\

I then have tried both running and debugging the project but either way, I still have to rebuild (CTRL-F9) between changes to the HTML.

Reading here from snicoll and dsayer this should be possible without the CTRL-F9:

Community
  • 1
  • 1
Doug Greaney
  • 181
  • 3
  • 17
  • Followed everything here and still doesn't work. Restart an all. * Spring Boot 2.1.2.RELEASE * IntelliJ 2018.3.4 Any other ideas? – szxnyc Feb 10 '19 at 20:16

2 Answers2

2

It appears after adding the registry setting :

compilier.automake.allow.when.app.running 

You need to restart not only the Springboot server but Intellij too.

It is going now.

Doug Greaney
  • 181
  • 3
  • 17
0

If you are still struggling with spring-boot-devtools, I recommend using Gulp to automate templates and resources reload. Following is a little Gulp task that does the magic for me:

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']);

I also wrote a short blog post on this topic which includes other methods as well.

attacomsian
  • 2,667
  • 23
  • 24