Spring Boot Release and Deployment - Development Hot Deployment

Spring Boot supports hot deployment of pages and class files.

spring-boot-devtools for hot deployment

The most important feature of spring-boot-devtools is hot deployment. It listens for file changes on the classpath and restarts the application immediately.

 

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

It is worth noting that optional=true means that dependencies will not be passed, in other words, other projects that depend on this project need to re-introduce if they want to use devtools.

If we want to restart Spring Boot when the files in the specified folder change, we only need to configure the information in src/main/resources/application.properties.

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

Spring Loaded implements hot deployment

Spring Loaded can also implement hot deployment of modified class files.

<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.

Template file hot deployment

In Spring Boot, the page of the template engine is cached by default. If the page content is modified, the modified page content cannot be obtained by refreshing the page. Therefore, if we do not need the cache of the template engine, we can close it.

spring.freemarker.cache=false
spring.thymeleaf.cache=false
spring.velocity.cache=false

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324963384&siteId=291194637