前提:
1. SpringBoot框架已经搭好。
2. IDEA。
1. pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
dependency放到dependencies下,plugin放到plugins下(build -> plugins)
2. application.yml
spring:
devtools:
restart:
enabled: true
exclude: WEB-INF/**
3. 设置IDEA
Mac:
1) IntelliJ IDEA -> Preferences -> Build,.... -> Compiler -> Build project automatically。
2) 按下command + shift + a,输入registry,找到compiler.automake.allow.when.app.running 。
Win:
1) File -> Settings -> Compiler -> Build Project automatically
2) ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running
大功告成!
参考文章:https://www.cnblogs.com/liu2-/p/9118393.html
来源:oschina
链接:https://my.oschina.net/nYtgEmMGe/blog/4304354