idea springboot开发编译所见即所得应用不需要重启

pom.xml
复制代码
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <!-- 使用 <optional>true</optional> 也可,防止依赖传递到其他模块 -->
    <optional>true</optional>
</dependency>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork> <!-- 如果没有此配置,devtools 可能不生效 -->
            </configuration>
        </plugin>
    </plugins>
</build>

开启自动编译

  1. 打开 File-> Settings(Windows/Linux) 或 IntelliJ IDEA-> Preferences(Mac)

  2. 导航到 Build, Execution, Deployment-> Compiler

  3. 勾选 Build project automatically

配置项目的运行选项
  1. 点击 IDEA 顶部菜单 Run-> Edit Configurations...

  2. 选择你的 Spring Boot 应用配置。

  3. 在右侧窗口中,找到 "On 'Update' action" 和 "On frame deactivation" 两个选项(如果看不到,请点击 "Modify options" 来展开)。

  4. 将它们的值都设置为 Update classes and resources

    • On 'Update' action :当你手动触发更新(快捷键 Ctrl + F10/ Cmd + F10,选择 Update)时的行为。

    • On frame deactivation:当 IDEA 窗口失去焦点时(例如你切换到浏览器窗口)的行为。

设置为 "Update classes and resources" 意味着无论是手动触发还是切换窗口,IDEA 都会尽力去更新类和静态资源。

相关推荐
kfyty72510 分钟前
集成 spring-ai 2.x 实践中遇到的一些问题及解决方案
java·人工智能·spring-ai
猫头虎12 分钟前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven
李少兄13 分钟前
在 IntelliJ IDEA 中修改 Git 远程仓库地址
java·git·intellij-idea
忆~遂愿33 分钟前
ops-cv 算子库深度解析:面向视觉任务的硬件优化与数据布局(NCHW/NHWC)策略
java·大数据·linux·人工智能
小韩学长yyds43 分钟前
Java序列化避坑指南:明确这4种场景,再也不盲目实现Serializable
java·序列化
仟濹44 分钟前
【Java基础】多态 | 打卡day2
java·开发语言
Re.不晚1 小时前
JAVA进阶之路——无奖问答挑战2
java·开发语言
Ro Jace2 小时前
计算机专业基础教材
java·开发语言
mango_mangojuice2 小时前
Linux学习笔记(make/Makefile)1.23
java·linux·前端·笔记·学习
程序员侠客行2 小时前
Mybatis连接池实现及池化模式
java·后端·架构·mybatis