Spring Boot 1.3 will ship with a brand new module called spring-boot-devtools. The aim of this module is to try and improve the development-time experience when working on Spring Boot applications.

To use the module you simply need to add it as a dependency in your Maven POM:

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

or your Gradle build file:

dependencies {
compile("org.springframework.boot:spring-boot-devtools")
}

Once included, the spring-boot-devtools module provides a number of nice features that we cover below (If you can’t be bother to read the text, skip to the end of the post for a short video).

Property Defaults

If you’ve used templating technologies such as Thymeleaf with Spring Boot 1.2, you might be familiar with properties such as spring.thymeleaf.cache. These properties are used to disable caching and allow you to update pages without needing to restart your application. Having support for these properties is pretty handy, but remembering to set them during development has always been a bit of a pain.

Now, when you use the spring-boot-devtools module, you no longer need to remember to set the properties. During development caching for Thymeleaf, Freemarker, Groovy Templates, Velocity and Mustache are all automatically disabled.

Automatic Restart

You may have used tools such as JRebel or Spring Loaded in the past to provide instant reload for your Java applications. These tools are great, but they do often require additional configuration or IDE plugins to work (and some of them even cost money!)

With Spring Boot 1.3 we’ve been working on something that’s a little slower than these “instant reload” techniques, and instead works by restarting your application. When you have the spring-boot-devtools module included, any classpath file changes will automatically trigger an application restart. We do some tricks to try and keep restarts fast, so for many microservice style applications this technique might be good enough.

LiveReload

With sensible “cache properties” and “automatic restarts” working, needing to manually click the browser refresh button each time something changes starts to become a little tedious. So to help save your mouse buttons, Spring Boot 1.3 DevTools includes an embedded LiveReload server. LiveReload is a simple protocol that allows your application to automatically trigger a browser refresh whenever things change. Browser extensions are freely available for Chrome, Firefox and Safari from livereload.com.

Remote Debug Tunneling

If you’ve ever tried to host a Java application using Docker, or if you’ve tried a micro PaaS such as Lattice, you may have been frustrated about how difficult it can be to debug your code. You need configure Java to start with -Xdebug and somehow forward the appropriate port so that you can attach the remote debugger.

To help with this, Spring Boot 1.3 can tunnel JDWP (the Java Debug Wire Protocol) over HTTP directly to your application. This can even work with applications deployed to Internet Cloud providers that only expose port 80 and 443 (although since JDWP is quite a chatty protocol this can be quite slow).

Remote Update and Restart

The final trick that DevTools offers is support for remote application updates and restarts. This works by monitoring your local classpath for file changes and pushing them to a remote server which is then restarted. As with local restarts, you can also use this feature in combination with LiveReload.

Video Preview

All the features discussed in this post are already available in Spring Boot 1.3.0.M1 and detailed documentation is available in the reference guide. If you’re not ready to install the bits yourself yet, here’s a short video that shows how they work:

original link:点击这个

DevTools in Spring Boot 1.3的更多相关文章

  1. spring boot 系列之五:spring boot 通过devtools进行热部署

    前面已经分享过四篇随笔: spring boot 系列之一:spring boot 入门 spring boot 系列之二:spring boot 如何修改默认端口号和contextpath spri ...

  2. 2019阿里P7最新总结Spring Boot面试问题

        Spring Boot一直是Spring生态系统的关键参与者.该项目通过其自动配置功能使我们的生活更加轻松.在本教程中,我们将介绍在求职面试中可能出现的一些与Spring Boot相关的最常见 ...

  3. Spring Boot 系列教程5-热部署-devtools模块

    devtools模块 devtools模块,是为开发者服务的一个模块.主要的功能就是代码修改后一般在5秒之内就会自动重新加载至服务器,相当于restart成功. 原理 简单原理 在发现代码有更改之后, ...

  4. Spring Boot 配置 IDEA&DevTools 自编译重启

    MAVEN 配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="ht ...

  5. Spring Boot新模块devtools

    Spring Boot 1.3中引入了一个新的模块,devtools. 顾名思义,这个模块是为开发者构建的,目的在于加快开发速度. 这个模块包含在最新释出的1.3.M1中. 自动禁用模板缓存 一般情况 ...

  6. spring boot 热部署devtools实现

    1.devtools spring为开发者提供了一个名为spring-boot-devtools的模块来使Spring Boot应用支持热部署,提高开发者的开发效率,无需手动重启Spring Boot ...

  7. 学习Spring Boot:(五)使用 devtools热部署

    前言 spring-boot-devtools 是一个为开发者服务的一个模块,其中最重要的功能就是自动应用代码更改到最新的App上面去.原理是在发现代码有更改之后,重新启动应用,但是比速度比手动停止后 ...

  8. Spring Boot系列教程三:使用devtools实现热部署

    一.前言 Eclipse下使用spring-tool-suite插件创建一个spring boot 工程,通过右键“Run As”--->"Spring Boot App"来 ...

  9. Spring Boot学习笔记-配置devtools实现热部署

    写在前面 Spring为开发者提供了一个名为spring-boot-devtools的模块来使Spring Boot应用支持热部署,提高开发者的开发效率,无需手动重启Spring Boot应用. de ...

随机推荐

  1. Python快速学习-函数

    函数定义总结: 1.定义函数时,需要确定函数名和参数个数:2.如果有必要,先对参数的数据类型进行检查:3.函数体内部可以用return随时返回函数结果:4.函数执行完毕没有return语句时,自动re ...

  2. 我的博客搬家到https://www.w2le.com/了

    大家以后想看我的博文的请到这里哦,欢迎大家访问https://www.w2le.com/

  3. 用find命令查找最近修改过的文件

    Linux的终端上,没有windows的搜索那样好用的图形界面工具,但find命令确是很强大的. 比如按名字查找一个文件,可以用 find / -name targetfilename . 唉,如果只 ...

  4. 《Advanced Bash-scripting Guide》学习(十):利用whois查询域名信息

    本文所选的例子来自于<Advanced Bash-scripting Gudie>一书,译者 杨春敏 黄毅 Example 4-6. wh,whois域名查询 #!/bin/bash #做 ...

  5. 时间服务器: NTP 服务器及客户端搭建

    时间服务器: NTP 服务器及客户端搭建 一. NTP 服务器的安装与设定 1. NTP 服务器的安装与设定前言 2. 所需软件与软件结构 3. 主要配置文件 ntp.conf 的处理 4. NTP ...

  6. C++中内部类访问外部类的私有成员

    首先,如果不知道什么是内部类InnerClass的话,就没必要往下看了. 尝试在C++中模仿apple objective-c 的Grand Dispatch简化多线程编程时,使用了boost::fu ...

  7. IDEA提交Git时忽略文件【ignore文件备份】

    IntellJ IDEA设置ignore文件忽略,需: 第一步:下载idea的ignore插件,链接:https://pan.baidu.com/s/14_cfq56g1s7Lc6LdiolvWA 密 ...

  8. svn文件大小类型限制,提交必须加多少字的说明

    #!/bin/sh REPOS="$1" TXN="$2" #此处更改大小限制,这里是5M MAX_SIZE= #此处增加限制文件后缀名 FILTER='\.( ...

  9. 原生JDBC的使用

    public class ConnDB { private Connection ct = null; //驱动程序名 String driver = "com.mysql.jdbc.Dri ...

  10. 一段tcl代码

    #!/usr/bin/wish proc icanspeak {} { set name [.ent get] } { exec s $name } } label .lab -text " ...