使用软件为IDEA,springboot开发,话不多说,直接说配置步骤:
1.首先在pom.xml文件中加入devtools依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
2.之后再application.xml文件中配置devtools,注意格式
spring:
devtools:
restart:
enabled: true #设置开启热部署
additional-paths: src/main/java #重启目录
exclude: WEB-INF/**
freemarker:
cache: false #页面不加载缓存,修改即时生效
把thymeleaf也配置一下
spring:
thymeleaf:
prefix:
classpath: /templates # 访问template下的html文件需要配置模板,映射
cache: false # 开发时关闭缓存,不然没法看到实时页面
mode: HTML
由于这两个都是spring下的配置 ,所以请自行合并
3.接着修改IDEA软件设置
(1) 如图勾选build project automatically
(2)ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running
4.接着重启项目,测试成功~
感谢阅读!