解决IDEA中spring boot项目热部署不生效

话不多说,直接开干!
我们先引入所需要的依赖。

  1. 插件配置
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-devtools</artifactId>
	<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
	<scope>true</scope>
</dependency>
  1. 添加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
在这里插入图片描述
现在就可以愉快的撸代码了!!!

发布了10 篇原创文章 · 获赞 0 · 访问量 3

猜你喜欢

转载自blog.csdn.net/qq_41994179/article/details/105542880