zoukankan      html  css  js  c++  java
  • 框架 Spring Boot 技术入门到整合 4-1 Springboot 使用devtools进行热部署

    0    课程地址

    https://www.imooc.com/video/16717

    1    idea热部署操作条件
    1.1  什么是热部署

    修改java类或页面或者静态文件,不需要手动重启

    1.2  配置热部署(主要针对类的修改会重启)

    a  pom.xml 引入devtools依赖

    <!-- 热部署 -->
            <!-- devtools可以实现页面热部署(即页面修改后会立即生效,
                这个可以直接在application.properties文件中配置spring.thymeleaf.cache=false来实现) -->
            <!-- 实现类文件热部署(类文件修改后不会立即生效),实现对属性文件的热部署。 -->
            <!-- 即devtools会监听classpath下的文件变动,并且会立即重启应用(发生在保存时机),
                注意:因为其采用的虚拟机机制,该项重启是很快的 -->
            <!-- (1)base classloader (Base类加载器):加载不改变的Class,例如:第三方提供的jar包。 -->
            <!-- (2)restart classloader(Restart类加载器):加载正在开发的Class。 -->
            <!-- 为什么重启很快,因为重启的时候只是加载了在开发的Class,没有重新加载第三方的jar包。 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <!-- optional=true, 依赖不会传递, 该项目依赖devtools;
                    之后依赖boot项目的项目如果想要使用devtools, 需要重新引入 -->
                <optional>true</optional>
            </dependency>

    b  application.properties 配置文件 配置

    #关闭缓存, 即时刷新
    #spring.freemarker.cache=false
    #spring.thymeleaf.cache为false时,页面热部署 #spring.thymeleaf.cache=true #热部署生效 spring.devtools.restart.enabled=true #设置重启的目录,添加那个目录的文件需要restart spring.devtools.restart.additional-paths=src/main/java

    c  idea配置自动编译

    1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。

    2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running”

  • 相关阅读:
    Bit Manipulation
    218. The Skyline Problem
    Template : Two Pointers & Hash -> String process
    239. Sliding Window Maximum
    159. Longest Substring with At Most Two Distinct Characters
    3. Longest Substring Without Repeating Characters
    137. Single Number II
    142. Linked List Cycle II
    41. First Missing Positive
    260. Single Number III
  • 原文地址:https://www.cnblogs.com/1446358788-qq/p/14015107.html
Copyright © 2011-2022 走看看