You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Spring Boot DevTools的Live reload功能无法正常工作

Troubleshooting Spring Boot DevTools LiveReload Not Working

Hey there, let's work through your LiveReload issue step by step. I've run into this exact problem a few times, so here are the most common fixes to check off:

1. Ensure the LiveReload Client is Connected

  • You need a LiveReload extension installed in your browser (like the ones for Chrome or Firefox). Make sure you've clicked the extension icon to activate it—it should turn solid (usually green) when connected to your running app.
  • Check your application's startup logs for a line like LiveReload server is running on port 35729. If you don't see this, DevTools might not be properly loaded in your app.

2. Verify Your DevTools Dependency Setup

  • Double-check that your spring-boot-devtools dependency is correctly placed in your project's build file. For Maven, it should be inside the <dependencies> block:
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    
  • If you're working with a multi-module project, ensure the dependency is added to your web/frontend-facing module, not just the parent pom.

3. Confirm You're Modifying Files in the Right Directories

  • Make sure the files you're editing are in one of the officially monitored directories: /META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates. Remember these paths are relative to src/main/resources (e.g., src/main/resources/static/js/app.js is part of the /static directory).

4. Check Your Spring Boot Configuration

  • Open your application.properties or application.yml and ensure you haven't accidentally disabled LiveReload or DevTools:
    • Set spring.devtools.livereload.enabled=true (this is default, but worth confirming)
    • Set spring.devtools.restart.enabled=true (restart support is required for LiveReload to function properly)
    • If you're still having issues, try adding spring.devtools.restart.additional-paths=src/main/resources to explicitly tell DevTools to monitor this directory.

5. Fix IDE Auto-Build Settings

  • IntelliJ IDEA:
    • Enable "Build project automatically" under Settings > Build, Execution, Deployment > Compiler
    • Open the Registry (press Ctrl+Shift+A and search for "Registry"), then enable compiler.automake.allow.when.app.running
  • Eclipse: Enable "Build Automatically" under the Project menu. Without auto-build, IDE changes won't be picked up by DevTools.

6. Clean Caches and Restart

  • Run a clean build (e.g., mvn clean for Maven) to clear any cached resources
  • Restart your Spring Boot application and browser—sometimes a fresh start fixes connection glitches
  • Avoid using browser incognito mode, as some LiveReload extensions don't work properly there

内容的提问来源于stack exchange,提问作者Kingamere

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:03:54