##一、在pom.xml的配置文件中加载热部署插件
< dependencies> </ dependencies>
<!-- 构建节点 -->
<build>
<plugins>
<!-- 在这里添加springloader plugin:热部署插件-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin </artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.4.RELEASE</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
##二、使用spring-boot:run方式进行热部署
如下图:pom.xml文件的空白处右击
直接修改(非新建)代码,就能看到修改后的效果。不需要重新编译。
但是,这种热部署方式有一个坏处:当程序停止后,后台进程不会自动关。需要再任务管理器中关闭进程。
##三、使用run as – java application方式进行热部署(推荐)
###1、将springloaded-1.2.4.RELEASE.jar包引入项目
###2、在主方法类中空白处右击,如下
-javaagent:.\lib\springloaded-1.2.4.RELEASE.jar -noverify
这样部署有一个好处,程序关闭,后台进程自动关闭,不需要我们手动关闭进程。
这样就可以访问啦。
![](https://i-blog.csdnimg.cn/blog_migrate/07df64cf5f8739d9e4ee18585da0bd9c.jpeg)