springboot中的热部署
在pom依赖中加入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
在plugin中加入fork标签
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
在application.properties中加入
#热部署设置
spring.devtools.restart.enabled=true
#设置重启的目录,添加目录的文件会被重新加载
spring.devtools.restart.additional-paths=src/main/java
#解决项目中重新编译报404的问题
spring.devtools.restart.poll-interval=3000
spring.devtools.restart.quiet-period=1000
当我们修改了java类后是不会自动编译的,而devtools是监控classpath中的文件发生变化才会重启,所以需要设置IDEA中的设置自动编译
file->settings->Compiler
Registry属性修改ctrl+shift+alt+/ 把下图打上对钩就行
可以按住 ctrl+F9快速启动