转自:

https://www.cnblogs.com/zhukf/p/12672180.html

一、什么是热部署?

热部署,就是在应用正在运行的时候升级软件,却不需要重新启动应用。

二、什么是SpringBoot热部署?

SpringBoot热部署就是在项目正在运行的时候修改代码, 却不需要重新启动项目。

有了SpringBoot热部署后大大提高了开发效率,因为频繁的重启项目,势必会浪费很多时间, 有了热部署后,妈妈再也不用担心我修改代码重启项目了~~~

三、SpringBoot热部署的流程

1.pom文件中导入 spring-boot-devtools 依赖:

1
2
3
4
5
6
<!--SpringBoot热部署配置 --><br><dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

2.继续在pom.xml中添加插件:

1
2
3
4
5
6
7
8
9
10
11
12
<build>
     <plugins>
     <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
         <configuration>
          <fork>true</fork>
                  <addResources>true</addResources>
         </configuration>
    </plugin>
     </plugins>
</build>

3.设置application.properties

1
2
#配置项目热部署
spring.devtools.restart.enabled=true

4.在idea中设置自动编译:

首先ctrl+alt+s打开设置(Other Settings 的设置是对整个工作空间项目都启作用,而Settings…的设置是对整个项目启作用),搜索Compliler,勾选Build project automatically,如下图所示:

5.按住ctrl + shift + alt + /,出现如下图所示界面,点击Registry...,如下图:

点击进入后,勾选compiler.automake.allow.when.app.running后关闭即可

通过以上步骤,就完成了SpringBoot项目的热部署功能!!!

6.对热部署测试是否成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.devtoolsDemo.devtoolsDemo.controller;
 
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/hello")
public class HelloDemo {
 
    @RequestMapping("/index")
    public String index() {
        return "helloworld!";
    }
     
}

启动项目,通过浏览器输入地址:http://localhost:8080/hello/index

结果如下:

新加请求,在不重新启动项目的情况下测试热部署是否配置成功~~~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.devtoolsDemo.devtoolsDemo.controller;
 
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/hello")
public class HelloDemo {
 
    @RequestMapping("/index")
    public String index() {
        return "helloworld!";
    }
 
    @RequestMapping("/say")
    public String say(){
        return "I love Java!";
    }
 
}

测试新加请求是否成功,浏览器输入http://localhost:8080/hello/say后结果如下:

说明我们的热部署配置生效啦~~~

idea设置springboot项目热部署的更多相关文章

  1. spring-boot项目热部署以及spring-devtools导致同类不能转换

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

  2. IDEA 配置Springboot项目热部署

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

  3. idea中gradle的springboot的项目热部署

    1:在build.gradle中添加热部署依赖(我gradle版本是5.5.1) // 添加 热部署依赖implementation 'org.springframework.boot:spring- ...

  4. Springboot静态文件不更新的解决办法,以及Springboot实现热部署

    Springboot静态文件不更新的解决办法,以及Springboot实现热部署 原文链接:https://www.cnblogs.com/blog5277/p/9271882.html 原文作者:博 ...

  5. idea+spring-boot+devtools热部署

    idea+spring-boot+devtools热部署 标签: spring-boot 2017-03-20 14:45 2635人阅读 评论(1) 收藏 举报  分类: spring-boot m ...

  6. SpringBoot工程+热部署进行远程调试

    本文转载自:https://blog.csdn.net/qq_31868349/article/details/78553901 SpringBoot工程+热部署进行远程调试 本地端添加配置 在pom ...

  7. SpringBoot工程热部署

    SpringBoot工程热部署 1.在pom文件中添加热部署依赖 <!-- 热部署配置 --> <dependency> <groupId>org.springfr ...

  8. SpringBoot SpringCloud 热部署 热加载 热调试

    疯狂创客圈 Java 高并发[ 亿级流量聊天室实战]实战系列 [博客园总入口 ] 架构师成长+面试必备之 高并发基础书籍 [Netty Zookeeper Redis 高并发实战 ] Crazy-Sp ...

  9. springBoot开启热部署

    springBoot开启热部署 这里使用devtools工具开启热部署 〇.搭建springbboot基础环境 一.添加依赖 <dependency> <groupId>org ...

  10. Eclipse中使用JRebel实现项目热部署(Maven插件版)

    JRebel实现项目热部署(Maven插件版) 热部署,就是在应用运行过程中不进行重启,可直接进行软件升级. 在开发过程中,热部署就是在项目运行过程中变更代码,无需重启服务器即可使代码生效. tomc ...

随机推荐

  1. 连接Oracle 19c出现ORA-28040:没有匹配的验证协议

    错误信息:ORA-28040:没有匹配的验证协议处理方法 出现这个原因是因为你的Oracle连接客户端与服务端Oracle的版本不匹配造成的.一般是低版本客户端连接高版本服务端出现. 高版本连接低版本 ...

  2. 重试机制的实现(Guava Retry)

    重试机制的实现 重试作用: 对于重试是有场景限制的,参数校验不合法.写操作等(要考虑写是否幂等)都不适合重试. 远程调用超时.网络突然中断可以重试.外部 RPC 调用,或者数据入库等操作,如果一次操作 ...

  3. HDLbits—— 3-input look-up-table

    // a 3-input look-up-table // In this question, you will design a circuit for an 8x1 memory, // wher ...

  4. HDLbits——Exams/m2014 q4k

    //四级移位寄存器 module top_module ( input clk, input resetn, // synchronous reset input in, output reg out ...

  5. MySQL的MDL锁

    MDL锁的概念和分类 1.MDL类型 锁名称 锁类型 说明 适用语句 MDL_INTENTION_EXCLUSIVE 共享锁 意向锁,锁住一个范围 任何语句都会获取MDL意向锁, 然后再获取更强级别的 ...

  6. js给ul下面所有的li追加类名

  7. tidb配置haproxy

    1.安装haproxy wget https://www.haproxy.org/download/2.6/src/haproxy-2.6.2.tar.gz make clean make -j 8  ...

  8. css - contenteditable

    css - contenteditable contenteditable属性 contenteditable 属性是 HTML5 中的新属性.规定是否可编辑元素的内容. 让contenteditab ...

  9. MAMP redis.conf 位置 , nginx.conf位置

    /Applications/MAMP PRO.app/Contents/Resources/redis.conf /Applications/MAMP/conf/nginx/nginx.conf /A ...

  10. WebService接口实际场景应用(一)

    背景:要求写一套接口测试工具.过程中遇到了WebService接口的问题,遂写下本篇文章. 阶段问题1: 需要利用数据驱动,然后读取excel中的数据并直接调用.但是webService接口与http ...