spring-boot热部署-1(第四篇)
我们在开发的过程中,时常会修改代码,一般情况下,是每次修改代码后再次启动tomcat运行服务,而这种频繁启动服务很麻烦,为了简化这种操作,引入springloaded热部署,这样就可以只需要启动一次服务即可,后续修改代码不用启动服务。
本节沿用springboot-json文章项目,操作如下
普通方式springboot(热部署)
在pom.xml文件中添加依赖包
<!-- 通过springloaded进行热部署 -->
<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>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
运行项目
Ø 方式一:使用spring-boot:run运行
选择项目,右键,run as .
Ø 方式二:
如果使用run as java applicaiton运行,需要做一些处理。下载spring-loader-1.2.4.RELEASE.jar,将下载的jar包方到lib目录中。
使用参数:-javaagent:.\lib\springloaded-1.2.4.RELEASE.jar –noverify 然后启动就可以。