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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

Auler   2021-03-16 我要评论
想了解Intellij IDEA实现springboot热部署过程解析的相关内容吗,Auler在本文为您仔细讲解Intellij IDEA springboot的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Intellij,IDEA,springboot,热部署,下面大家一起来学习吧。

对于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/**

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们