Spring Boot Devtools not working using Gradle
Asked Answered
A

0

6

I have created a simple Spring Boot app using IntelliJ that use Spring Boot Devtools as dependency and Gradle as build automation with option: Use default gradle wrapper. However, the Devtools seems not working. When I change my html file, the page does not updated even though I refresh it several times. I use Spring Boot Devtools docs as reference.

My application.properties is empty

Here is my build.gradle:

buildscript {
ext {
    springBootVersion = '2.0.5.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile("org.springframework.boot:spring-boot-devtools")
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

Interesting fact: I have tried in several Spring Boot versions (from 1.5.12.RELEASE until 2.1.0.RELEASE), but the result is still the same.

But when I switch from Gradle to Maven, the Devtools surprisingly worked!

Any clue anyone? I want to use Gradle, not Maven.

Additional information:

  • OS: Ubuntu 18.04
  • IDE: IntelliJ 2018.2
  • Java: openjdk 11 2018-09-25
  • Gradle version: 4.8.1
  • Gradle JVM: java version 1.8.0__151
  • Gradle run method: ./gradlew bootRun
  • Maven version: 3.5.2
  • Maven run method: mvn spring-boot:run
Ascogonium answered 30/11, 2018 at 10:12 Comment(4)
Could you please add errors logs?Attaint
Here is the log . Actually, there is no error message appeared (because I use the default log level, which is INFO), but if needed, I can provide the debug message log.Ascogonium
Seems all is OK, could you please try with gradle only? if you don't have one, install and put gradle bootRunAttaint
I installed Gradle 4.8.1 (same as the Gradle wrapper) and run gradle bootRun but still not working. Actually in my description above, I run Gradle and Maven separately, not together, just want to know if I use Maven, it will work or not.Ascogonium

© 2022 - 2024 — McMap. All rights reserved.