IDEA 配置Springboot项目热部署

一、实现的方式概述

注意以下的热部署方式在IDEA是默认没有打开自动编译的,手动编译需要快捷键(Ctrl+Shift+F9),自动编译的修改配置如下:(注意刷新不要太快,会有1-2秒延迟)

File-Settings-Compiler-Build Project automatically

二、spring-boot-devtools

在pom中直接引入依赖

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

设置以下两项(第一项如已设置直接设置第二项)

  • 1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。
  • 2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running” 。

之后直接正常run即可!

三 spring-loaded

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <!-- spring热部署 -->
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>1.2.6.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

// 如果依赖提示not found,先在上面写让maven下载下来,再移到Plugin里面来

命令行窗口启动

找到pom.xml的路径,IDEA的话打开Pom后在标签页鼠标悬停即可看到,或者在pom上右击->file Path

在这个路径下打开cmd窗口(win下可以通过shift快速在对应路径打开),输入启动命令

mvn spring-boot:run
    这样就可以在IDE里修改代码实现热加载了!
热部署加载原理 可以参考 http://www.importnew.com/17115.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
配置Spring Boot热部署,你可以按照以下步骤进行操作: 1. 在你的项目的pom.xml文件中,添加spring-boot-devtools的依赖,并确保在<optional>标签中设置为true。这样可以确保在开发阶段使用热部署功能。 2. 在maven-plugin上添加配置,以支持热部署。同时,确保修改IDEA设置,打开自动编译,并允许在程序运行过程中进行编译。 3. 修改spring-boot-maven-plugin插件的配置,设置<fork>标签为true。这样可以确保在重新启动应用程序时,使用新的类加载器加载修改后的类。 通过以上步骤,你就可以成功配置IDEA实现Spring Boot热部署的功能了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [【SpringBoot学习】2、idea 配置 SpringBoot 热启动详解,和热启动失效解决方案](https://blog.csdn.net/qq_38762237/article/details/81094425)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [SpringBoot设置热部署(超详细)【IDEA版】](https://blog.csdn.net/weixin_43883917/article/details/115398023)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值