八.热部署
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>