【发布时间】:2016-02-25 11:23:18
【问题描述】:
Spring Boot devtools 1.3 的新 LiveReload 功能存在问题。它不会在类更改时重新加载。我已经在 IntelliJ @ Devoxx 2015 上看到过它的演示。我需要启用一些 IDE 设置吗?我通过 IDE 运行,而不是通过 Gradle。我尝试启用“自动制作项目”,但这似乎没有帮助。
它似乎加载正确并且正在寻找正确的路径
2015-11-23 05:55:30.592 DEBUG 4700 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Starting application com.myapp.Application with URLs [file:/E:/Projects/myapp/build/classes/main/, file:/E:/Projects/myapp/build/resources/main/]
我的文件
build.gradle
buildscript {
ext {
springBootVersion = '1.3.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'myapp'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.projectlombok:lombok')
compile('org.springframework.boot:spring-boot-starter-web')
compile('net.sourceforge.jtds:jtds:1.3.1');
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.M3"
}
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
HelloWorldController
@Controller
public class HelloWorldController {
@RequestMapping("/")
@ResponseBody
String home(){
return "Hello World test";
}
}
【问题讨论】:
-
答案要点:此功能会在 target/ 文件夹中的 .class 文件更改时重新启动服务器,而不是在您仅更改源 .java 文件时重新启动服务器。当您保存更改的源代码文件时,有一种方法可以强制 intellij 更新类路径上的 .class 文件。但是,此功能旨在与自动执行此操作的 eclipse ide 一起使用。
-
对我来说,我在 STS 中更新 [检查自动构建] 转到 windows -> 首选项 -> 构建
-
我发现了一个奇怪的变化;使用 Firefox 版本的插件,livereload 对某些页面来说就像一个魅力,但对其他页面则不然。切换到 Chrome,它适用于所有页面。可能是 Firefox 扩展中的错误?