博客
关于我
Spring Boot——开发热部署及常用工具
阅读量:389 次
发布时间:2019-03-05

本文共 1238 字,大约阅读时间需要 4 分钟。

Spring Boot 开发热部署及常用工具

在开发过程中,频繁修改 Java 文件后需要重启应用会导致效率低下。为了实现热部署(即无需重启应用即可生效的部署方式),Spring Boot 提供了几种常用方法。

一、热部署

热部署的实现主要有以下几种情况:

  • 模板引擎配置

    在 Spring Boot 项目中,禁用模板引擎的缓存功能。这样可以确保页面模板的更改能够及时生效。具体操作如下:

    • 修改 application.properties 文件,添加配置 spring.thymeleaf.cache=false
    • 在需要修改模板的时候,右键点击模板文件,选择 Compile Current File(trl+F9),即可生效修改。
  • Spring Boot Devtools

    Spring Boot 提供了 Devtools 插件,能够实现热部署。以下是使用 Devtools 的步骤:

    • 在项目的 pom.xml 文件中添加 Devtools 依赖:
      org.springframework.boot
      spring-boot-devtools
    • 在 IDEA 中,使用 ctrl+F9 快捷键重新编译项目,会自动部署修改后的文件。
    • 注意:IDEA 和 Eclipse 在 Devtools 功能上存在差异。建议根据具体 IDE 进行相应设置。
  • IDEA 自动编译设置

    • 打开 Settings,选择 Compiler > Build, Execution, Deployment > ** Compiler**。
    • 勾选 Build project automatically(自动编译项目)。
    • 勾选 compiler.automake.allow.when.app.running(允许在应用运行时自动编译)。
  • 二、RestfulToolkit

    RestfulToolkit 是一个常用的工具,支持直接调试 RESTful 接口:

    • 功能特点

      • 可以查看项目中所有使用 @RequestMapping 注解的方法。
      • 提供 HTTP 请求模拟功能,类似 Postman。
    • 安装方法

      • 打开 IDEA 插件市场,搜索并安装 RestfulToolkit 插件。
      • 插件安装完成后,重启 IDEA。

    三、Save Actions 格式化工具

    Save Actions 插件可以帮助开发者在编码过程中更高效地格式化代码:

    • 安装方法

      • 打开 IDEA 的插件市场,搜索并安装 Save Actions 插件。
      • 插件安装完成后,重启 IDEA。
    • 配置方法

      • 打开 Settings,选择 Editor > Code Style > Save Actions
      • 根据需要配置代码格式化规则。

    通过以上工具和方法,开发者可以在不重启应用的情况下实现热部署,提升开发效率。

    转载地址:http://zjnwz.baihongyu.com/

    你可能感兴趣的文章
    nnU-Net 终极指南
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    NO 157 去掉禅道访问地址中的zentao
    查看>>
    no available service ‘default‘ found, please make sure registry config corre seata
    查看>>
    No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    查看>>
    no connection could be made because the target machine actively refused it.问题解决
    查看>>
    No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
    查看>>
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
    查看>>
    No module named 'crispy_forms'等使用pycharm开发
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    no session found for current thread
    查看>>