在IDEA中如何使用spring的热部署
1、添加maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
<scope>true</scope>
</dependency>
2、插件配置
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 没有该配置,devtools 不生效 -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
但是在实际使用中发现即便这样配置之后,还是没有作用,这是为什么呢?
这是因为idea默认是没有自动编译的,我们这里需要添加修改配置.打开设置
1、File-Settings-Compiler-Build Project automatically

2、ctrl + shift + A 然后输入Registry

然后勾上 Compiler autoMake allow when app running

然后就可以开心的撸代码了
网友评论