springboot开启热部署和禁用热部署

1.关于热部署:

启(Restart):自定义开发代码,包含类、页面、配置文件等,加载位置restart类加载器

重载(ReLoad):jar包,加载位置base类加载器

热部署仅仅加载当前开发者自定义开发的资源,不加载jar资源

2.启动热部署

首先,想要启动热部署功能,首先我们需要在pom.xml中添加入下的配置。

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

 在springboot现在的版本中不需要我们手动添加devtools的配置,在我们创建springboot项目的时候就可以勾选该配置即可。

 

3.设置自动启动热部署 

        1.在file--> setting--> Build,Execution,Depliyment -->Compiler中勾选Build project automatically

 

        2.接下来就是在以前的版本idea中和新版idea中设置是不同的,在以前的版本中我们需要组合键Ctrl+Shift+Alt+/,选择Registry,然后勾选如图所示。

 

 

        3.但是在新版的idea中在 Registry中没有该选项,此时我们就需要在在file--> setting--> Advanced Setting 中去勾选Allow auto-make to start even if developed application is curently runing就可以了。

 

 4.热部署范围配置

1.默认不触发 重启的目录列表
/META-INF/maven
/META-INF/resources
/resources
/static
/public

           /templates

2.自定义不参与重启排除项

devtools:
  restart:
    exclude: pages/**,static/**

 5.禁用热部署

设置高优先级属性禁用热部署

package com.stu;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Springboot12HotDeployApplication {

    public static void main(String[] args) {
        SpringApplication.run(Springboot12HotDeployApplication.class, args);
    }

}
修改成如下即可
public static void main(String[] args) {            
    System.setProperty("spring.devtools.restart.enabled", "false");   
    SpringApplication.run(Springboot12HotDeployApplication.class);
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序小白学编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值