热部署和冷部署有什么区别_weblogic热部署
生活随笔
收集整理的這篇文章主要介紹了
热部署和冷部署有什么区别_weblogic热部署
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?博客主頁:?不會壓彎的小飛俠
✨歡迎關注:?點贊?收藏⭐留言✒
✨系列專欄:?SpringBoot專欄(每日更新)
✨如果覺得博主的文章還不錯的話,請三連支持一下博主。
?歡迎大佬指正,一起 學習!一起加油!
?前言
熱部署,就是不需要停掉服務,可以線上改,改完立馬生效。
?為什么要使用熱部署
因為不啟用熱部署時每次更改java數據都要重啟服務器影響開發效率。
?關于熱部署:
- 重啟(Restart)∶自定義開發代碼,包含類、頁面、配置文件等,加載位置restart類加載器
- 重載(ReLoad) : jar包,加載位置base類加載器
?手動啟動熱部署
?導入坐標 – 啟動開發者工具
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
Jetbrains全家桶1年46,售后保障穩定
?修改數據
方便測試是否啟用了熱部署:
詳細代碼:點擊直接查看
@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
?測試
?自動啟動熱部署
自動啟動熱部署步驟:
filesetting- 搜索
Compiler,在右側勾上 “Build project automatically”- 快鍵鍵
Ctrl+atl+shift+/- 點擊
Registry- 勾選第一行這個如下圖
?熱部署范圍配置
如果想要某些文件或者文件夾不參與熱部署的配置需要在application.xml中配置以下信息:
# 設置不參與熱部署的文件或文件夾
devtools:
restart:
exclude: static/**,public/**,config/application.yml
?禁用熱部署
?方式一
在application.yml中配置:
# 設置不參與熱部署的文件或文件夾
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的地方禁用熱部署功能:
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);
}
}
總結
以上是生活随笔為你收集整理的热部署和冷部署有什么区别_weblogic热部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转载]Scikit Learn: 在p
- 下一篇: POJ 1155 TELE 背包型树形