话不多说,直接开干!
我们先引入所需要的依赖。
- 插件配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
<scope>true</scope>
</dependency>
- 添加maven依赖
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 没有该配置,devtools 不生效 -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
————————————————————————————————————
当我们引入依赖之后,我们会发现这样配置后还是没有起作用,先不要着急,且听我慢慢道来。
其实原因很简单,就是idea默认创建的项目默认是没有自动编译的,我们需要修改一下idea的设置内容。
1、打开设置:File-Settings-Compiler-Build Project automatically
2、ctrl + shift + A 然后输入Registry
然后勾上 Compiler autoMake allow when app running
现在就可以愉快的撸代码了!!!