一、IDEA配置
当我们修改了Java类后,IDEA默认是不自动编译的,而spring-boot-devtools又是监测classpath下的文件发生变化才会重启应用,所以需要设置IDEA的自动编译:
(1)File->Settings->Compiler->Build Project automatically
(2)File->Settings->Advanced settings->Allow auto-make to start even if developed application iss currently running
二、Spring Boot XML配置
Spring Boot XML配置文件引入依赖devTools
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency>
XML 配置,build增加fork
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> </build>
三、Resources下面的YML配置
spring: devtools: restart: enabled: true