idea中springboot项目开启热部署

在开发的时候,我们需要实时地看到效果,这时就需要实现项目热部署了,当我们修改了类后,可以进行实时编译部署,下面我们总结一下,在idea中实现热部署的步骤。

  1. 在pom.xml中加上依赖和插件
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <scope>true</scope>
    </dependency>
    
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <fork>true</fork>
        </configuration>
    </plugin>
    
  2. 在application.properties中开启热部署
    spring.devtools.remote.restart.enabled=true
    
  3. 开启IDEA的即使编译设置,windows和mac略有不同,大家大概知道,然后自行找一下
    打开IDEA的Preferences,点击Compiler,然后在右侧我们可以看到有Build project automatically这个选项,我们勾选上,一定要记着点击Apply,然后再点击OK。
    在这里插入图片描述
    这个设置之后,还有一个地方,windows点击ctrl+shift+alt+/,mac点击cmd+shift+a,打开之后找到Registry,点击再打开一个,找到compiler.automake.allow.when.app.running,勾选上,点击close就可以了,然后重启IDEA。
    在这里插入图片描述

在这里插入图片描述
以上就是所有的步骤。

猜你喜欢

转载自blog.csdn.net/weixin_45345374/article/details/112942674