当前位置: 移动技术网 > IT编程>开发语言>Java > Intellij IDEA实现springboot热部署过程解析

Intellij IDEA实现springboot热部署过程解析

2020年08月31日  | 移动技术网IT编程  | 我要评论
对于springboot热部署貌似是这样的,首先要设置idea相关配置导航栏 file -> settings -> build,execution,deployment -> co

对于springboot热部署貌似是这样的,首先要设置idea相关配置

导航栏 file -> settings -> build,execution,deployment -> compiler 选择build project automatically 打勾 如下图所示

接着ctrl+shift+alt+/ 快捷键选择registry会弹出如下图

在红色选择的一行打勾,就完成了这步骤。

接着开始配置pom.xml文件

<dependencies>
<dependency>
  <groupid>org.springframework.boot</groupid>
  <artifactid>spring-boot-devtools</artifactid>
  <optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
  <!-- springboot maven plugin -->
  <plugin>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-maven-plugin</artifactid>
   <configuration>
     <!--fork : 如果没有该项配置,肯定devtools不会起作用,即应用不会restart -->
     <fork>true</fork>
   </configuration>
  </plugin>
</plugins>

</build>

pom文件也配置好了,就开始配置application.yml (或者 application.properties)

  #thymeleaf
 spring:
  thymeleaf:
   cache: false #这里一定要设置false 
   prefix: classpath:/thymeleaf/
   suffix: .html
   mode: html5
   encoding: utf-8
  devtools:
    restart:
      #热部署生效true
      enabled: true
      #设置重启的目录
      additional-paths: resources/**,static/**,templates/**
      #该目录下的内容修改不重启
     exclude: data/**

配置完之后,基本上就可以运行了,还有最后要记得浏览器要设置 禁止缓存

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网