1.1、在pom.xml文件中加入

<build>
        <plugins>
            <!--热部署: 在这里添加springloader plugin -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin </artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>1.2.4.RELEASE</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>exec</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- 热部署:这是spring boot devtool plugin -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!--fork : 如果没有该项配置,devtools不会起作用,即应用不会restart -->
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
    </build>

1.2、鼠标右键启动准备

八.热部署

八.热部署

1.3基于idea的运行方式、eclipse也可以使用

一、使用springloaded-1.2.4.RELEASE.jar 加入到项目的lib目录

二、配置以下:-javaagent:.\lib\springloaded-1.2.4.RELEASE.jar –noverify

八.热部署

一、热启动:每自修改后, 程序自动启动spring Application上下文,Pom中.xml直接添加依赖即可

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

这里需要注意的是每次类文件更改后需要重新编译方可触发服务重新启动

二、热交换或热部署

这个使用springloaded插件

<build>  
        <plugins>  
            <plugin>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-maven-plugin</artifactId>  
                <dependencies>  
                    <!-- spring热部署 -->  
                    <dependency>  
                        <groupId>org.springframework</groupId>  
                        <artifactId>springloaded</artifactId>  
                        <version>1.2.6.RELEASE</version>  
                    </dependency>  
                </dependencies>  
            </plugin>  
        </plugins>  
</build>

相关文章:

  • 2021-04-10
  • 2021-09-25
  • 2021-05-03
  • 2021-06-16
  • 2021-06-28
  • 2021-06-20
  • 2022-01-13
猜你喜欢
  • 2021-08-15
  • 2021-12-12
  • 2021-07-11
相关资源
相似解决方案