SpringBoot 熱部署
開發中,每次對類的修改,都需要重啟服務,很浪費時間,影響效率
,所以就需要用到熱部署,節省時間提高效率,
1、在Maven的pom.xml檔案中添加依賴
<!--Spring Boot提供了一個名為spring-boot-devtools的模塊來使應用支持熱部署,提高開發者的開發效率,無需手動重啟Spring Boot應用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<!-- optional=true,依賴不會往下傳遞,如果有專案依賴本專案,并且想要使用devtools,需要重新引入 -->
<optional>true</optional>
</dependency>
2、繼續在Maven的pom.xml檔案中添加插件的配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--自動啟動-->
<configuration>
<!--fork:如果沒有該項配置,整個devtools不會起作用-->
<fork>true</fork>
</configuration>
</plugin>
<!--自定義配置spring Boot使用的JDK版本-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
3、組態檔application.yml中添加
debug: true
spring:
devtools:
remote:
restart:
enabled: true #設定開啟熱部署
freemarker:
cache: false #頁面不加載快取,修改及時生效
如果是Eclipse,配置到這里,只要重啟服務,熱部署就會生效了,
但是IDEA的話,熱部署還不會生效,因為devTools只會在類路徑上的檔案發生更改時才會自動重啟,而IDEA默認不會自動編譯,
1)File -> Settings -> Compliler,勾選Build Project automatically

2)按快捷鍵Ctrl+Shift+Alt+/,選擇1.Registry

3)勾選compiler.automake.allow.when.app.running即可

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/17290.html
標籤:Windows
上一篇:Mybatis獲取自動增長Id
下一篇:檔案上傳
