SpringBoot中怎樣實現(xiàn)熱部署

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)SpringBoot中怎樣實現(xiàn)熱部署,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

成都創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的新民網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

1、引用devtools依賴

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

這樣,當(dāng)修改一個java類時就會熱更新。

2、自定義配置熱部署

以下配置用于自定義配置熱部署,可以不設(shè)置。

# 熱部署開關(guān),false即不啟用熱部署spring.devtools.restart.enabled: true# 指定熱部署的目錄#spring.devtools.restart.additional-paths: src/main/java# 指定目錄不更新spring.devtools.restart.exclude: test/**

3、Intellij Idea修改

如果是idea,需要改以下兩個地方:

1、勾上自動編譯或者手動重新編譯

File > Settings > Compiler-Build Project automatically

2、注冊

ctrl + shift + alt + / > Registry > 勾選Compiler autoMake allow when app running

注意事項

1、生產(chǎn)環(huán)境devtools將被禁用,如java -jar方式或者自定義的類加載器等都會識別為生產(chǎn)環(huán)境。

2、打包應(yīng)用默認(rèn)不會包含devtools,除非你禁用SpringBoot Maven插件的excludeDevtools屬性。

3、Thymeleaf無需配置spring.thymeleaf.cache: false,devtools默認(rèn)會自動設(shè)置,點擊參考完整屬性。

下面是devtools自動配置的部分源碼:

@Order(Ordered.LOWEST_PRECEDENCE)public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor {  private static final Map<String, Object> PROPERTIES;  static {    Map<String, Object> properties = new HashMap<String, Object>();    properties.put("spring.thymeleaf.cache", "false");    properties.put("spring.freemarker.cache", "false");    properties.put("spring.groovy.template.cache", "false");    properties.put("spring.mustache.cache", "false");    properties.put("server.session.persistent", "true");    properties.put("spring.h3.console.enabled", "true");    properties.put("spring.resources.cache-period", "0");    properties.put("spring.resources.chain.cache", "false");    properties.put("spring.template.provider.cache", "false");    properties.put("spring.mvc.log-resolved-exception", "true");    properties.put("server.jsp-servlet.init-parameters.development", "true");    PROPERTIES = Collections.unmodifiableMap(properties);  }

4、devtools會在windows資源管理器占用java進(jìn)程,在開發(fā)工具里面殺不掉,只能手動kill掉,不然重啟會選成端口重復(fù)綁定報錯。

上述就是小編為大家分享的SpringBoot中怎樣實現(xiàn)熱部署了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

分享題目:SpringBoot中怎樣實現(xiàn)熱部署
文章起源:http://muchs.cn/article30/pdgdso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊、全網(wǎng)營銷推廣、ChatGPT網(wǎng)站導(dǎo)航、網(wǎng)站制作網(wǎng)頁設(shè)計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)