求助: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-devtoolsdependency 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 tosrc/main/resources(e.g.,src/main/resources/static/js/app.jsis part of the/staticdirectory).
4. Check Your Spring Boot Configuration
- Open your
application.propertiesorapplication.ymland 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/resourcesto explicitly tell DevTools to monitor this directory.
- Set
5. Fix IDE Auto-Build Settings
- IntelliJ IDEA:
- Enable "Build project automatically" under
Settings > Build, Execution, Deployment > Compiler - Open the Registry (press
Ctrl+Shift+Aand search for "Registry"), then enablecompiler.automake.allow.when.app.running
- Enable "Build project automatically" under
- Eclipse: Enable "Build Automatically" under the
Projectmenu. Without auto-build, IDE changes won't be picked up by DevTools.
6. Clean Caches and Restart
- Run a clean build (e.g.,
mvn cleanfor 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
相关产品推荐
相关产品推荐

