Spring Boot 进行热部署

1.介绍

在编写代码的时候,你会发现我们只是简单把打印信息改变了下,就需要重新部署,如果是这样的编码方式,那么我们估计一天下来之后就真的是打几个Hello World之后就下班了。那么如何解决热部署的问题呢?

添加如下依赖:

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

添加如下build:

<build>
      <plugins>
              <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin </artifactId>
              </plugin>
              <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>

当系统通过 mvn spring-boot:run启动或者 右键application debug 启动Java文件时,系统会监视classes文件,当有classes文件被改动时,系统会重新加载类文件,不用重启启动服务。

Github地址:https://github.com/spring-boot-learn/springboot04

 

参考文献

1. Spring Boot学习总结(4)——使用Springloaded进行热部署

posted @ 2017-07-15 16:27  pfnie  阅读(120)  评论(0)    收藏  举报