Springboot Hot Deployment

Source: Internet
Author: User

1.spring-boot-devtools for hot deployment

The most important feature of spring-boot-devtools is thermal deployment. It listens for file changes under Classpath and restarts the app immediately.

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId> Spring-boot-devtools</artifactid>    <optional>true</optional></dependency>

Optional=true means that dependencies are not passed, in other words, other projects that depend on the project, and if you want to use Devtools, you need to reintroduce

If you want to restart Spring boot when the file under the specified folder changes, we just need to configure the information in Src/main/resources/application.properties.

spring.devtools.restart.additional-paths= # Additional paths to watch for changes.

Custom Configuration Hot Deployment

The following configuration is used to customize the configuration of a hot deployment, and can not be set.

# Hot Deploy switch, false that does not enable hot deployment spring.devtools.restart.enabled:true# The specified hot deployment directory #spring.devtools.restart.additional-paths:src/ main/java# The specified directory is not updated spring.devtools.restart.exclude:test/**

If it is IntelliJ idea, you need to change the following two places:

1. Automatically compile on hook or manually recompile

File > Settings > Compiler-build Project automatically

2. Registration

CTRL + SHIFT + ALT +/> Registry > Tick compiler automake allow when app running

Precautions

1, production environment devtools will be disabled, such as Java-jar mode or a custom class loader, etc. will be recognized as a production environment.

2. The packaged app will not include Devtools by default unless you disable the properties of the Springboot maven plugin excludeDevtools .

3, thymeleaf no configuration spring.thymeleaf.cache:false , Devtools is automatically set by default, refer to the full properties.

https://github.com/spring-projects/spring-boot/blob/v1.5.7.RELEASE/spring-boot-devtools/src/main/java/org/ Springframework/boot/devtools/env/devtoolspropertydefaultspostprocessor.java

4, Devtools will occupy the Java process in Windows Explorer, in the development tool can not kill, only manually kill, or restart will be selected as the port repeated binding error.

2.Spring Loaded for thermal deployment
<plugin>    <groupId>org.springframework.boot</groupId>    <artifactId> spring-boot-maven-plugin</artifactid>    <dependencies>        <dependency>            <groupid >org.springframework</groupId>            <artifactId>springloaded</artifactId>            <version >1.2.6.RELEASE</version>        </dependency>    </dependencies></plugin>

Start the project with MVN Spring-boot:run.

Official Document: Https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html

Springboot Hot Deployment

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.