SpringBoot03 项目热部署

1 问题

  在编写springBoot项目时,经常需要修改代码;但是每次修改代码后都需重新启动,修改的代码才会生效

2 这么实现IDEA能够像Eclipse那样保存过后就可以自动进行刷新呢

  将springBoot项目进行热部署即可

3 如何实现SpringBoot项目的热部署01

  3.1 在插件中添加热部署所需的依赖

    SpringBoot03 项目热部署

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>cn.springBoot</groupId>
<artifactId>springBootProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springBootProject</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> <!--mysql驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--jpa,类似于连接池-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency> <!--mybatis相关-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<!-- alibaba的druid数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.11</version>
</dependency>
<!--分页查询相关-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.1</version>
</dependency> </dependencies> <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> </project>

  3.2 在设置中对compiler选项进行如下设置

    SpringBoot03 项目热部署

  3.3 设置registry

    进入快捷键:ctrl + shift + alt + /

    SpringBoot03 项目热部署

   3.4 修改完这些配置后重启IDEA再重新启动项目就实现了SpringBoot项目的热部署

4 如何实现springboot项目的热部署02

  4.1 引入相关依赖包

<!--热部署相关-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

  4.2 插件配置

    SpringBoot03 项目热部署

  4.2 修改IDEA设置

    SpringBoot03 项目热部署

    SpringBoot03 项目热部署

  4.3 修改全局设置

    SpringBoot03 项目热部署

参考博客:点击前往

上一篇:nodejs异步请求重试策略总结


下一篇:7-(基础入门篇)关于STM32底层程序使用说明