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

Spring Boot(spring-boot-starter-web)在IntelliJ中热交换功能失效求助

Troubleshooting Spring Boot DevTools Hot Swap Not Working in IntelliJ

Hey there, let's work through this hot swap issue step by step— I’ve been in your exact situation before and know how frustrating it is when devtools doesn’t kick in as expected!

  • Double-Check Your DevTools Dependency
    While runtime scope is valid, let’s confirm your dependency block is clean (and add the optional flag, which helps avoid propagating devtools to other modules accidentally):

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    

    Also make sure there are no accidental exclusion rules for devtools in your build file.

  • Verify IntelliJ’s Hidden Registry Settings
    The compiler.automake.allow.when.app.running setting isn’t the only one that matters. Press Ctrl+Shift+A (Windows/Linux) or Cmd+Shift+A (Mac), search for Registry, and ensure these two are checked:

    • compiler.automake.allow.when.app.running
    • actionSystem.assertFocusAccessFromEdt (This can interfere with auto-build triggers if disabled)
  • Force-Enable DevTools Restart
    Sometimes restart gets disabled silently via config. Add these lines to your application.properties to explicitly turn it on:

    spring.devtools.restart.enabled=true
    # Optional: Specify custom paths to watch if your code lives in non-standard directories
    spring.devtools.restart.additional-paths=src/main/java
    
  • Check Your Run Configuration
    Make sure you’re running the app via IntelliJ’s Spring Boot Run Configuration, not a packaged JAR or external command line. Devtools only works in development mode (when using spring-boot:run or the IDE’s native run tool).

  • Try a Manual Build Trigger
    Even with auto-build enabled, IntelliJ sometimes needs a nudge. After making code changes, press Ctrl+F9 (Windows/Linux) or Cmd+F9 (Mac) to trigger a manual build— this should kick off the devtools restart immediately.

  • Check for Excluded Paths
    Devtools ignores certain files by default, but custom exclusions might be blocking your code. Verify your application.properties doesn’t exclude your source directories:

    # Ensure these don't cover your code paths
    spring.devtools.restart.exclude=static/**,public/**
    
  • Invalidate IntelliJ Caches
    Stale cache data often causes weird IDE behavior. Go to File > Invalidate Caches... and select "Invalidate and Restart"— this clears out any corrupted data that might be breaking auto-build.

I’ve fixed this issue more times than I can count, and 90% of the time it was either a missing Registry setting or forgetting to trigger a manual build. Give these steps a shot and let me know which one works for you!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:55:20