在我使用IDEA的过程中,我发现Spring Boot项目本来自带的一个热部署工具无法使用,这里在参考各家博客后给出解决方案:
修改POM
首先POM文件需要包含spring boot的热部署工具,maven依赖如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
这里需要注意,这个optional选项指定为true
增加一个编译工具的配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
这里注意,这个fork选项值为true
更改IDEA配置
项目POM文件配置完成后修改IDEA的自己一个配置,配置地址为:
Setting→Build,ExecutionDeployment→Compiler,如下图所示
点击Apply,然后使用快捷键 shift+ctrl+alt+/,有一个小窗口,如下:
按数字1,然后选择compiler.automake.allow.when.app.running,把勾选上
然后点击close就好了
PS:IDEA版本2018.2.4