eip-admin-starter-views 工程导入了devtools热部署工具,用户在修改完静态资源后不需要再手动重启工程。具体使用方法如下:
- 确认依赖和插件导入,eip-admin-starter-views 工程已导入依赖和插件,使用前首先进行确认
<!--引入热部署组件-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>true</scope>
<optional>true</optional>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
- 确认配置文件正确,相关配置信息在 application.yml 中
#热部署工具
devtools:
restart:
enabled: true #设置开启热部署
additional-paths: src/main/java #重启目录
exclude: WEB-INF/**
freemarker:
cache: false #页面不加载缓存,修改即时生效
同时确保thymeleaf缓存为false
thymeleaf:
# 开发改为false、生产改为true
cache: false
- idea开启自动编译
设置【idea】→【File】→【Settings】→【build project automatically】→ 选中 - idea设置Registry
设置【idea】→【File】→【Settings】→【Registry】,找到并勾选compiler.automake.allow.when.app.running
这样就可以使用前端热加载了,用户更改静态资源后不需要手动重启工工程,idea即会自动重新编译静态资源。