IDEA提高前端开发速度
idea的热部署设置
说明
- 该配置没有用到artifact,网上有些教程使用ctrl+shift+alt+S,通过打包模块来部署,但本文没有用到。
- 本文主要通过配置pom.xml
步骤
-
更改pom.xml
一定要注意pom.xml中对应的文件夹中要有main函数。pox.xml在需要更新的项目中更改,父文件夹和子文件夹没有必要的关系,不可修改父文件夹的pox.xml.
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>true</scope>
<optional>true</optional>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 没有该配置,devtools 不生效 -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
其中idea会提示import,点击即可
-
选择自动构建项目
依次点击File -> Settings ->Build,Executions,Deployment -> Compiler ,勾选下图所示:
-
使用快捷键Ctrl + Shift + Alt + \ ,点击registry,勾选value的复选框,如下:
-
配置application.yml,禁用缓存
spring:
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML
encoding: utf-8
servlet:
content-type: text/html
cache: false
- 现在,可以更改html文件,ctrl+s保存更改,再刷新界面,或者重新点击子页面,就可以看到更改了,无需重新部署Tomact。