MAVEN Engineering uses Spring-boot-devtools for hot deployment, changing code to avoid restarting the Web container

Source: Internet
Author: User

Spring-boot-devtools is a module for developers, and the most important feature is the automatic application of code changes to the latest apps. Related blog: Click to open the link

The principle is to restart the application after discovering that the code has changed, but faster than the speed of the manual stop, and faster than the time saved by manual operation.

The underlying principle is to use two ClassLoader, one ClassLoader to load the classes that will not change (third-party jar packages), and another ClassLoader to load the changed classes, called Restart ClassLoader

, so that when there is code change, the original restart ClassLoader is discarded, re-create a restart ClassLoader, due to the need to load fewer classes, so a faster restart time (less than 5 seconds).

Since Devtools is only in Spring milestone repository. Warehouse is available, and the default warehouse version is 1.2.5.RELEASE, so you need to configure the warehouse address in the Pom.xml file.

[HTML]View PlainCopy
  1. <repositories>
  2. <repository>
  3. <ID>spring-milestones</ID>
  4. <name>spring milestones</name>
  5. <URL>http://repo.spring.io/milestone</url>
  6. <snapshots>
  7. <enabled>false</enabled>
  8. </Snapshots>
  9. </repository>
  10. </repositories>


Then change the parent label

[HTML]View PlainCopy
  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactid>spring-boot-starter-parent</artifactid>
  4. <version>1.3.0.m2</version>
  5. </Parent>

Finally add the module dependency can be


[HTML]View PlainCopy
    1. <dependency>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactid>spring-boot-devtools</artifactid>
    4. </Dependency>

As for the use of the module, as long as the dependency is written in the line, do not need other special action, use the example click here to have a video show, or pretty clear.


Pay special attention to Because the inheritance of the Pom.xml version is 1.3.0.m2, the original dependent on the inside if you omit version, but in the 1.3.0.m2 without the module will be error, this time only need to manually add the dependent version coordinates, written as the original 1.2.5.RELEASE can be.

Note the point:

1.spring-boot-tools and Spring-boot versions to be consistent

MAVEN Engineering uses Spring-boot-devtools for hot deployment, changing code to avoid restarting the Web container

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.