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

IntelliJ CE中spring-boot-devtools自动重载失效问题求助

IntelliJ CE实现Spring Boot类修改自动重启(媲美Eclipse Boot Dashboard)

1. 确认Spring DevTools配置

  • 检查pom.xml中spring-boot-devtools依赖无provided scope(默认已正确引入,需确保配置未被修改):
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    
  • 在application.properties或application.yml添加重启优化配置:
    # 启用自动重启
    spring.devtools.restart.enabled=true
    # 指定监听修改的核心路径
    spring.devtools.restart.additional-paths=src/main/java,src/main/resources
    # 排除静态资源,避免不必要的重启触发
    spring.devtools.restart.exclude=static/**,public/**
    # 调小监听间隔,提升响应速度
    spring.devtools.restart.poll-interval=100ms
    spring.devtools.restart.quiet-period=50ms
    
  • 验证Lombok配置:开启Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors -> Enable annotation processing,确保Lombok插件处于激活状态。

2. 配置IntelliJ自动构建触发重启

  • 开启自动构建:进入Settings -> Build, Execution, Deployment -> Compiler,勾选Build project automatically
  • 允许运行时自动构建:按Ctrl+Shift+A(Windows/Linux)或Cmd+Shift+A(Mac)搜索Registry,找到compiler.automake.allow.when.app.running并勾选
  • 调试模式补充配置:进入Settings -> Build, Execution, Deployment -> Debugger,勾选Allow auto-make to start even if developed application is currently running

3. 正确的启动方式

  • 直接运行主类:找到带@SpringBootApplication的主类,右键选择Run 'XXXApplication'或Debug 'XXXApplication',无需使用mvn spring-boot:run(避免远程调试繁琐流程)
  • 修改代码/资源文件后,IntelliJ会自动触发构建,DevTools将在2秒内完成应用重启

4. 常见问题排查

  • 检查目录标记:确保src/main/java、src/main/resources未被标记为Excluded(右键目录 -> Mark Directory as -> 取消Excluded状态)
  • 同步Maven依赖:点击右侧Maven面板的Reload All Maven Projects,确保所有依赖正常加载
  • 清除IntelliJ缓存:执行File -> Invalidate Caches... -> Invalidate and Restart,解决缓存导致的异常

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 08:15:04