Springboot在intelliJ中使用热部署配置不生效的解决办法

首先要在Maven的pom.xml文件中添加依赖

<!-- 热部署配置 -->
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <optional>true</optional>
</dependency>
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<fork>true</fork> <!-- 如果没有该配置,热部署的devtools不生效 -->  
					<addResources>true</addResources>
				</configuration>
			</plugin>
		</plugins>
	</build>

如果是Eclipse,配置到这里,只要重启服务,热部署就会生效了  

使用Intellij的话需要在Build,Execution,Deployment下找到Compiler 勾选  Build  project automatically,如图

Springboot在intelliJ中使用热部署配置不生效的解决办法

这时候还没完,还需要我们按住Ctrl+Shift+Alt+/ 弹出窗口选择Registry..

Springboot在intelliJ中使用热部署配置不生效的解决办法

然后勾选 compiler.automake.allow.when.app.running 

Springboot在intelliJ中使用热部署配置不生效的解决办法

ok  这样在Intellij中Spring boot就可以热部署了