spring boot 之热部署

spring boot使用的是spring-boot-devtools是一个为开发者服务的一个模块。其原理用了classLoader 其中一个加载不变的类,另一个restart ClassLoader加载变得类。

devtools会监听classpath下的文件变动,并且会立即重启应用(发生在保存时机)。

    不说废话,我喜欢的Coding就是简单and直接。我写代码一般都是截图,不会粘代码,目的是让你们能敲一遍,我认为程序是敲出来的不是看出来的。你们要懂我的良苦用心。

  一、pom的依赖直接添加坐标。

<!--spring boot devtools 热启动依赖包 start-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <scope>true</scope>
        </dependency>
        <!--spring boot devtools 热启动依赖包 end-->

二、编译节点添加。

        <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!--如果不配值将不会起作用-->
                    <fork>true</fork>
                </configuration>
            </plugin>    

 

 参考: http://www.cnblogs.com/winner-0715/p/6666579.html

   

原文地址:https://www.cnblogs.com/faunjoe88/p/7735526.html