自动编译springgidea设置 boot代码,idea代码修改后立即生效,无需重启服务
时间:2025-06-24 12:51:36 来源:新华社
【字体:  

一、背景。

系统环境:windows 10。
idea版本󿄚IntelliJ IDEA 2022.2.3 (Ultimate Edition)。
springBoot版:2.2.6.RELEASE。

Spring Boot开发应用程序时,需要频繁修改和调试代码。

为提高开发效率,希望能自动编译和热更新应用程序,在修改代码后,我们不需要手动重新启动应用程序。

二、解决方案。

1、在pom.以下依赖项添加到xml文件中。

org.springframework.boot。spring-boot-devtools。runtime。true。

spring-boot-Springgdevtools依赖项目 Boot开发工具,它提供了自动编译和热更新的功能。

2、设置IDEA自动编译。

打开IDEA,选择“File” -> “Settings” -> “Build, Execution, Deployment” -> “Compiler”。

在右栏中,勾选“。Build project automatically。”选项。这样,在保存文件时,IDEA将自动触发编译过程。

在这里插入图片描述

3、设置Spring Boot热更新。

IDEA,选择“Run” -> “Edit Configurations”。

在这里插入图片描述

在弹出对话框中,选择你的Spring boot应用程序配置󿀌

点击右侧“Modify options",找到“On frame deactivation选项,并选择“Update classes and resources”。
在这里插入图片描述
在这里插入图片描述

这样,在。IDEA失去了焦点。时,应用程序将自动更新类别和资源。

4、运行Spring Boot应用程序。

࿰在IDEA中c;打开“src/main/java目录,并找到Spring 开始测试Boot应用程序的入口类。

[责任编辑:百度一下]
检察日报数字报 | 正义网 |
Copyrights©最高人民检察院 All Rights Reserved.