我使用 IntelliJ 创建了一个简单的 Spring Boot 应用程序,它使用 Spring Boot Devtools 作为依赖项,使用 Gradle 作为构建自动化选项:Use default gradle wrapper
. 但是,Devtools 似乎无法正常工作。当我更改我的 html 文件时,即使我刷新了几次页面也不会更新。我使用Spring Boot Devtools 文档作为参考。
我application.properties
的是空的
这是我的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')
}
有趣的事实:我已经尝试了几个 Spring Boot 版本(从1.5.12.RELEASE
until 2.1.0.RELEASE
),但结果仍然相同。
但是当我从 Gradle 切换到 Maven 时,Devtools 出人意料地工作了!
任何线索任何人?我想使用 Gradle,而不是 Maven。
附加信息:
- 操作系统:Ubuntu 18.04
- IDE:IntelliJ 2018.2
- 爪哇:
openjdk 11 2018-09-25
- 摇篮版本:4.8.1
- 摇篮JVM:
java version 1.8.0__151
- Gradle运行方法:
./gradlew bootRun
- Maven版本:3.5.2
- Maven运行方法:
mvn spring-boot:run