mac idea springboot 设置热部署

mac idea springboot 设置热部署

mac idea springboot 设置热部署

开发环境:IntelliJ IEAD + SpringBoot + Thymeleaf


加maven依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>


开启热部署

<plugins>
   <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
              <configuration>
                  <fork>true</fork>
              </configuration>
              <dependencies>
                  <!-- spring热部署-->
                  <!-- https://mvnrepository.com/artifact/org.springframework/springloaded -->
                  <dependency>
                      <groupId>org.springframework</groupId>
                      <artifactId>springloaded</artifactId>
                      <version>1.2.8.RELEASE</version>
                      <scope>test</scope>
                  </dependency>
              </dependencies>
   </plugin>

</plugins>


application.yml

spring:
  devtools:
    restart:
      enabled: true
      #additional-paths: src/main/java

  thymeleaf:
    cache: false



IntelliJ IEAD设置

1、IntelliJ IEAD --> Preferences -->  Build,Execution,Deployment --> Compiler --> Build project automatically选中

2、CTRL + SHIFT + A --> 查找Registry --> 找到并勾选 compiler.automake.allow.when.app.running 

注意:CTRL + SHIFT + A可能快捷键无效,先去IntelliJ IEAD --> Preferences --> keymap 中配置Registry的快捷键