IntelliJ 15,SpringBoot devtools livereload 不工作

新手上路,请多包涵

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/]

我的文件

构建.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'
}

你好世界控制器

@Controller
public class HelloWorldController {

    @RequestMapping("/")
    @ResponseBody
    String home(){

        return "Hello World test";
    }
}

原文由 Timm-ah 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 404
2 个回答

我猜你正在编码并期望 DevTools 自动神奇地发现你在你的项目中改变了一些东西? Devtools 通过观察你的类路径文件夹来做到这一点。当 .class 文件(或资源)发生更改时,devtools 会采取适当的措施。

如果您没有看到任何东西,那可能是因为您只是在编码而不是更新类路径。您必须调用 Make Project 来更新类路径。请参阅 文档

原文由 Stephane Nicoll 发布,翻译遵循 CC BY-SA 3.0 许可协议

如果您使用 IntelliJ IDEA,添加 spring-boot-devtools 是不够的。这是因为与 Eclipse 不同,您需要明确告诉 IntelliJ IDEA“制作项目”,以便将其构建到目标类路径。

在 youtube 上看到

最简单的解决方案: 运行应用程序调试模式并按 Ctrl + f9 (构建的快捷方式)

或者

  1. 您需要启用“自动生成项目”选项。你可以在 Settings - Build, Execution, Deployment - Compiler 中找到它
  2. 要打开注册表,请按 Ctrl-Alt-Shift-/ 并从出现的菜单中选择“注册表”,启用“compiler.automake.allow.when.app.running”复选框。

自动构建项目

编译器-automake-allow-when-app-running

原文由 i.karayel 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进