前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >热部署和冷部署有什么区别_weblogic热部署

热部署和冷部署有什么区别_weblogic热部署

作者头像
全栈程序员站长
发布于 2022-11-17 08:54:28
发布于 2022-11-17 08:54:28
1.5K00
代码可运行
举报
运行总次数:0
代码可运行

🍁博客主页:👉不会压弯的小飞侠 ✨欢迎关注:👉点赞👍收藏⭐留言✒ ✨系列专栏:👉SpringBoot专栏(每日更新) ✨如果觉得博主的文章还不错的话,请三连支持一下博主。 🔥欢迎大佬指正,一起 学习!一起加油!


目录


🍁前言

热部署,就是不需要停掉服务,可以线上改,改完立马生效。


🍁为什么要使用热部署

因为不启用热部署时每次更改java数据都要重启服务器影响开发效率。

🔥关于热部署:

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

🍁手动启动热部署

🔥导入坐标 – 启动开发者工具

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>

Jetbrains全家桶1年46,售后保障稳定

🔥修改数据

方便测试是否启用了热部署: 详细代码:点击直接查看

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 @GetMapping("{id}")
    public R getById(@PathVariable Integer id){ 
   
        System.out.println("host deploy...");
        System.out.println("host deploy...");
        System.out.println("host deploy...");
        return new R(true, bookService.getById(id));
    }

🔥build project

也可以使用快捷键:ctrl + shift9

🔥测试

🍁自动启动热部署

自动启动热部署步骤:

  1. file
  2. setting
  3. 搜索Compiler,在右侧勾上 “ Build project automatically
  1. 快键键Ctrl+atl+shift+/
  2. 点击Registry
  1. 勾选第一行这个如下图

🍁热部署范围配置

如果想要某些文件或者文件夹不参与热部署的配置需要在application.xml中配置以下信息:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# 设置不参与热部署的文件或文件夹
devtools:
  restart:
    exclude: static/**,public/**,config/application.yml 

🍁禁用热部署

🔥方式一

在application.yml中配置:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# 设置不参与热部署的文件或文件夹
devtools:
  restart:
    exclude: static/**,public/**,config/application.yml enabled: false 

这种形式关闭热部署,优先级别太低,可能关闭之后,别人又从别的配置文件或者其他地方给打开了(在优先级别高的地方),从而导致热部署在此启动.

🔥方式二

🔥在优先级别高的地方禁用热部署。

  • 属性加载优先顺序:由低到高
    • 1 Default properties (specified by setting springApplication.setDefaultproperties )
    • 2 GPropertySsource annotations on your @Cconfiguration classes. Please note that such property sources are not added to theEnvironment until the application context is being refreshed.This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.
    • 3 Config data (such as application.properties files)
    • 4 A RandomValuePropertySource that has properties only in random.* .
    • 5 OS environment variables.
    • 6 Java System properties ( system.getProperties() ).
    • 7 JNDl attributes from java:comp/env .
    • 8 ServletContext init parameters.
    • 9 Servletconfig init parameters.
    • 10 Properties from spRING_APpLICATION_soN (inline JSON embedded in an environment variable or system property).
    • 11 Command line arguments.
    • 12 properties attribute on your tests.Available on gSpringRootTest and the test annotations for testing a particular slice ofyour application.
    • 13 @TestPropertySource annotations on your tests.
    • 14 Devtools global settings properties in the SHN’E .config/spring-boot directory when devtools ,s.ati

🔥application.yml配置文件在优先级为3的地方,可以在优先级为6的地方禁用热部署功能:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.jkj;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootHotDeployApplication { 
   
    public static void main(String[] args) { 
   
        System.setProperty("spring.devtools.restart.enabled","false");
        SpringApplication.run(SpringbootHotDeployApplication.class);
    }

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/223041.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年10月29日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
💥开发者 MCP广场重磅上线!
精选全网热门MCP server,让你的AI更好用 🚀
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验