在開發的過程當中,咱們常常是修改了代碼以後,須要從新編譯,再啓動服務器使修改的部分生效。修改代碼-->從新編譯-->重啓服務器 這種方式很浪費時間。熱部署技術已經很成熟了,以下是實現步驟
#1.在插件中配置依賴包(springloaded.jar)spring
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.5.RELEASE</version> </dependency> </dependencies> <!-- <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <fork>true</fork> </configuration>--> </plugin> </plugins> </build>
#2.舉例
controller層代碼
請求輸出
修改controller代碼
不重啓服務器,直接從新編譯一下就行,快捷鍵(ctrl+shift+f9)
至此結束。springboot
備註:springboot1.5.2的版本本身已經支持熱部署了,jar包是服務器
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <version>1.5.2.RELEASE</version> </dependency>