在依赖中添加 ,依赖后直接重启(Eclipse)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
通常直接见效。
如果无效,则配置插件
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
注:热部署应用了jdk1.8新特性 :java.lang.annotation.Repeatable,
也可能有jdk版本低的原因。
在IDEA中需要更改默认的编译设置
路径:file-settings-compiler-build project automatically,通过快捷键Ctrl+Shift+Alt+/后选择Registry,勾选compiler.automake.allow.when.app.running app 运行时允许编译。