1. 問題:
我們?cè)陧?xiàng)目開發(fā)階段,可能經(jīng)常會(huì)修改代碼,修改完后就要重啟Spring Boot。經(jīng)常手動(dòng)停止再啟動(dòng),比較麻煩。
所以我們引入一個(gè)Spring Boot提供的開發(fā)工具;
只要源碼或配置文件發(fā)生修改,Spring Boot應(yīng)用可以自動(dòng)重啟,這樣子我們做如下事情就會(huì)事半功倍:
- 修改類–>保存:應(yīng)用會(huì)重啟
- 修改配置文件–>保存:應(yīng)用會(huì)重啟
- 修改頁面–>保存:應(yīng)用不會(huì)重啟,但會(huì)重新加載,頁面會(huì)刷新-
2. 使用方法:
添加如下依賴到pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
3. 解決未重新啟動(dòng)的操作:
我用的2022版本的idea,較新一點(diǎn)
第一步:File->Settings->Build,Exception,Deployment->Compiler->Build Project automatically
第二步:File -> Settings -> Advanced Settings -> Allow auto-make to start even if developed application is currently running
勾選然后apply,然后ok就好了??!
快去試試吧
舊版本的IDEA第二步試試這樣子??!文章來源:http://www.zghlxwxcb.cn/news/detail-623011.html
ctrl + shift + alt + / ,選擇Registry,勾上 Compiler autoMake allow when app running文章來源地址http://www.zghlxwxcb.cn/news/detail-623011.html
到了這里,關(guān)于springboot項(xiàng)目如何自動(dòng)重啟(使用Devtools檢測(cè)修改并自動(dòng)重啟springboot)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!