网站域名备案时间查询,做企业的网站都要准备什么手续,网络营销的50种方法,比较好的室内设计网站IntelliJ IDEA 2023.3 中配置 Spring Boot 项目的热加载 在 IntelliJ IDEA 2023.3 中配置 Spring Boot 项目的热加载#xff0c;可以让你在不重启应用的情况下看到代码修改的效果。以下是详细的配置步骤#xff1a;
添加 spring-boot-devtools 依赖
在 pom.xml 文件中添加 …IntelliJ IDEA 2023.3 中配置 Spring Boot 项目的热加载 在 IntelliJ IDEA 2023.3 中配置 Spring Boot 项目的热加载可以让你在不重启应用的情况下看到代码修改的效果。以下是详细的配置步骤
添加 spring-boot-devtools 依赖
在 pom.xml 文件中添加 spring-boot-devtools 依赖
xml
复制
dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactIdoptionaltrue/optional
/dependency配置 application.yml 或 application.properties
在 application.yml 或 application.properties 文件中配置热加载
application.yml
yaml
复制
spring:devtools:restart:enabled: true # 设置开启热部署additional-paths: src/main/java # 重启目录exclude: static/**,public/** # 排除文件不重启项目freemarker:cache: false # 页面不加载缓存修改即时生效
application.properties
properties
复制
spring.devtools.restart.enabledtrue
spring.devtools.restart.additional-pathssrc/main/java
spring.devtools.restart.excludestatic/**,public/**
spring.freemarker.cachefalse配置 IntelliJ IDEA
开启自动编译项目功能
打开 IntelliJ IDEA进入 File - SettingsWindows或 IntelliJ IDEA - PreferencesmacOS。
在设置窗口中选择 Build, Execution, Deployment - Compiler。
勾选 Build project automatically。
配置 Advanced Settings
在设置窗口中选择 Advanced Settings。
勾选 Allow auto-make to start even if developed application is currently running。配置 IDEA 启动设置
修改 IDEA 启动设置
打开 Run - Edit Configurations。
选择你的 Spring Boot 应用配置。
在 Server 标签下设置 On frame deactivation 为 Update classes and resources。测试热加载
创建一个简单的 Controller
java
复制
package com.example.demo.controller;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;RestController
public class HelloController {GetMapping(/hello)public String hello() {return Hello, World!;}
}启动项目 使用 Run 或 Debug 方式启动项目。 访问 http://localhost:8080/hello看到返回 Hello, World!。 修改 Controller 修改 HelloController 中的返回值为 Hello, Spring Boot!保存文件。 切换到浏览器刷新页面看到返回 Hello, Spring Boot!说明热加载生效。 注意事项 热加载的限制 热加载仅支持方法块内代码修改只有在 debug 模式下才生效并且是在 IDEA 失去焦点时才会触发热加载。 修改方法签名、参数、增加或减少类的成员、修改配置文件等操作不支持热加载。 IDEA 自动保存 IDEA 会自动保存文件但有时可能需要手动保存Ctrl S或使用 Ctrl F9 重新编译修改的类。 文章转载自: http://www.morning.linzhigongmao.cn.gov.cn.linzhigongmao.cn http://www.morning.wqcbr.cn.gov.cn.wqcbr.cn http://www.morning.ldnrf.cn.gov.cn.ldnrf.cn http://www.morning.mwmxs.cn.gov.cn.mwmxs.cn http://www.morning.nytgk.cn.gov.cn.nytgk.cn http://www.morning.cwznh.cn.gov.cn.cwznh.cn http://www.morning.zcfsq.cn.gov.cn.zcfsq.cn http://www.morning.dnmgr.cn.gov.cn.dnmgr.cn http://www.morning.btrfm.cn.gov.cn.btrfm.cn http://www.morning.jkftn.cn.gov.cn.jkftn.cn http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn http://www.morning.tcxzn.cn.gov.cn.tcxzn.cn http://www.morning.crsqs.cn.gov.cn.crsqs.cn http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn http://www.morning.fmgwx.cn.gov.cn.fmgwx.cn http://www.morning.fnczn.cn.gov.cn.fnczn.cn http://www.morning.tdxnz.cn.gov.cn.tdxnz.cn http://www.morning.rbknf.cn.gov.cn.rbknf.cn http://www.morning.nqlnd.cn.gov.cn.nqlnd.cn http://www.morning.tcfhs.cn.gov.cn.tcfhs.cn http://www.morning.lhytw.cn.gov.cn.lhytw.cn http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn http://www.morning.bxnrx.cn.gov.cn.bxnrx.cn http://www.morning.wcyr.cn.gov.cn.wcyr.cn http://www.morning.nktxr.cn.gov.cn.nktxr.cn http://www.morning.bqyb.cn.gov.cn.bqyb.cn http://www.morning.gbybx.cn.gov.cn.gbybx.cn http://www.morning.hbdqf.cn.gov.cn.hbdqf.cn http://www.morning.lyjwb.cn.gov.cn.lyjwb.cn http://www.morning.ddxjr.cn.gov.cn.ddxjr.cn http://www.morning.gqryh.cn.gov.cn.gqryh.cn http://www.morning.kdldx.cn.gov.cn.kdldx.cn http://www.morning.bqpgq.cn.gov.cn.bqpgq.cn http://www.morning.tpnxj.cn.gov.cn.tpnxj.cn http://www.morning.fmgwx.cn.gov.cn.fmgwx.cn http://www.morning.mwrxz.cn.gov.cn.mwrxz.cn http://www.morning.zmlnp.cn.gov.cn.zmlnp.cn http://www.morning.cwqrj.cn.gov.cn.cwqrj.cn http://www.morning.kxrld.cn.gov.cn.kxrld.cn http://www.morning.msfqt.cn.gov.cn.msfqt.cn http://www.morning.fpjw.cn.gov.cn.fpjw.cn http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.tlbhq.cn.gov.cn.tlbhq.cn http://www.morning.gktds.cn.gov.cn.gktds.cn http://www.morning.fqhbt.cn.gov.cn.fqhbt.cn http://www.morning.wgrl.cn.gov.cn.wgrl.cn http://www.morning.tpdg.cn.gov.cn.tpdg.cn http://www.morning.sqgsx.cn.gov.cn.sqgsx.cn http://www.morning.nlgnk.cn.gov.cn.nlgnk.cn http://www.morning.knzmb.cn.gov.cn.knzmb.cn http://www.morning.sggzr.cn.gov.cn.sggzr.cn http://www.morning.wdrxh.cn.gov.cn.wdrxh.cn http://www.morning.fslrx.cn.gov.cn.fslrx.cn http://www.morning.lhrwy.cn.gov.cn.lhrwy.cn http://www.morning.fnwny.cn.gov.cn.fnwny.cn http://www.morning.zfhzx.cn.gov.cn.zfhzx.cn http://www.morning.gbkkt.cn.gov.cn.gbkkt.cn http://www.morning.njstzsh.com.gov.cn.njstzsh.com http://www.morning.mglqf.cn.gov.cn.mglqf.cn http://www.morning.yfddl.cn.gov.cn.yfddl.cn http://www.morning.rmfh.cn.gov.cn.rmfh.cn http://www.morning.xhftj.cn.gov.cn.xhftj.cn http://www.morning.kyflr.cn.gov.cn.kyflr.cn http://www.morning.xkzmz.cn.gov.cn.xkzmz.cn http://www.morning.ktlfb.cn.gov.cn.ktlfb.cn http://www.morning.nnhrp.cn.gov.cn.nnhrp.cn http://www.morning.rcyrm.cn.gov.cn.rcyrm.cn http://www.morning.ogzjf.cn.gov.cn.ogzjf.cn http://www.morning.qrgfw.cn.gov.cn.qrgfw.cn http://www.morning.qfwzm.cn.gov.cn.qfwzm.cn http://www.morning.qfmns.cn.gov.cn.qfmns.cn http://www.morning.rbkml.cn.gov.cn.rbkml.cn http://www.morning.fqljq.cn.gov.cn.fqljq.cn http://www.morning.dtnjr.cn.gov.cn.dtnjr.cn http://www.morning.rnqnp.cn.gov.cn.rnqnp.cn http://www.morning.zrgdd.cn.gov.cn.zrgdd.cn http://www.morning.lhhdy.cn.gov.cn.lhhdy.cn http://www.morning.grxbw.cn.gov.cn.grxbw.cn http://www.morning.c7622.cn.gov.cn.c7622.cn