Home Java javaTutorial How Spring Boot implements hot deployment

How Spring Boot implements hot deployment

Feb 14, 2020 pm 02:31 PM
spring boot Hot deployment

How Spring Boot implements hot deployment

How to implement hot deployment in Spring Boot

It is a very simple thing to implement hot deployment of code in Spring Boot, and the code modification can be automatically Deploy and restart the project.

1. Quote the devtools dependency

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

In this way, when a java class is modified, it will be hot updated.

2. Customized configuration hot deployment

The following configuration is used for customized configuration hot deployment and does not need to be set.

# 热部署开关,false即不启用热部署
spring.devtools.restart.enabled: true
# 指定热部署的目录
#spring.devtools.restart.additional-paths: src/main/java
# 指定目录不更新
spring.devtools.restart.exclude: test/**
Copy after login

3. Intellij Idea modification

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

1. Check automatic compilation or manually re-compile Compile

File > Settings > Compiler-Build Project automatically

2, Register

ctrl shift alt / > Registry > Check Compiler autoMake allow when app running

Notes

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

2. Packaged applications will not include devtools by default unless you disable the excludeDevtools attribute of the SpringBoot Maven plug-in.

3. Thymeleaf does not need to configure spring.thymeleaf.cache: false. devtools will automatically set it by default. Click to refer to the complete properties.

The following is part of the source code for the automatic configuration of devtools:

@Order(Ordered.LOWEST_PRECEDENCE)
public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor {
    private static final Map<String, Object> PROPERTIES;
    static {
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("spring.thymeleaf.cache", "false");
        properties.put("spring.freemarker.cache", "false");
        properties.put("spring.groovy.template.cache", "false");
        properties.put("spring.mustache.cache", "false");
        properties.put("server.session.persistent", "true");
        properties.put("spring.h2.console.enabled", "true");
        properties.put("spring.resources.cache-period", "0");
        properties.put("spring.resources.chain.cache", "false");
        properties.put("spring.template.provider.cache", "false");
        properties.put("spring.mvc.log-resolved-exception", "true");
        properties.put("server.jsp-servlet.init-parameters.development", "true");
        PROPERTIES = Collections.unmodifiableMap(properties);
    }
Copy after login

4. Devtools will occupy the java process in the Windows Resource Manager and cannot be killed in the development tools. It can only be killed manually, otherwise After restarting, the port will be selected for repeated binding and an error will be reported.

For more related content, please pay attention to PHP Chinese website.

The above is the detailed content of How Spring Boot implements hot deployment. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1262
29
C# Tutorial
1235
24
Spring Boot+MyBatis+Atomikos+MySQL (with source code) Spring Boot+MyBatis+Atomikos+MySQL (with source code) Aug 15, 2023 pm 04:12 PM

In actual projects, we try to avoid distributed transactions. However, sometimes it is really necessary to do some service splitting, which will lead to distributed transaction problems. At the same time, distributed transactions are also asked in the market during interviews. You can practice with this case, and you can talk about 123 in the interview.

How to use Spring Boot to build big data processing applications How to use Spring Boot to build big data processing applications Jun 23, 2023 am 09:07 AM

With the advent of the big data era, more and more companies are beginning to understand and recognize the value of big data and apply it to business. The problem that comes with it is how to handle this large flow of data. In this case, big data processing applications have become something that every enterprise must consider. For developers, how to use SpringBoot to build an efficient big data processing application is also a very important issue. SpringBoot is a very popular Java framework that allows

How to hot deploy Tomcat How to hot deploy Tomcat Dec 28, 2023 pm 05:41 PM

Tomcat hot deployment steps: 1. Place the project web folder directly in webapps; 2. Add the Context tag to the server.xml file; 3. Add the XML file to "%tomcat_home%\conf\Catalina\localhost"; 4. Release the project; 5. Precautions; 6. Use third-party tools; 7. Performance and stability; 8. Security; 9. Monitoring and logging; 10. Documentation and support.

Achieve multi-language support and international applications through Spring Boot Achieve multi-language support and international applications through Spring Boot Jun 23, 2023 am 09:09 AM

With the development of globalization, more and more websites and applications need to provide multi-language support and internationalization functions. For developers, implementing these functions is not an easy task because it requires consideration of many aspects, such as language translation, date, time and currency formats, etc. However, using the SpringBoot framework, we can easily implement multi-language support and international applications. First, let us understand the LocaleResolver interface provided by SpringBoot. Loc

Building an ESB system using Spring Boot and Apache ServiceMix Building an ESB system using Spring Boot and Apache ServiceMix Jun 22, 2023 pm 12:30 PM

As modern businesses rely more and more on a variety of disparate applications and systems, enterprise integration becomes even more important. Enterprise Service Bus (ESB) is an integration architecture model that connects different systems and applications together to provide common data exchange and message routing services to achieve enterprise-level application integration. Using SpringBoot and ApacheServiceMix, we can easily build an ESB system. This article will introduce how to implement it. SpringBoot and A

Integration and use of Spring Boot and NoSQL database Integration and use of Spring Boot and NoSQL database Jun 22, 2023 pm 10:34 PM

With the development of the Internet, big data analysis and real-time information processing have become an important need for enterprises. In order to meet such needs, traditional relational databases no longer meet the needs of business and technology development. Instead, using NoSQL databases has become an important option. In this article, we will discuss the use of SpringBoot integrated with NoSQL databases to enable the development and deployment of modern applications. What is a NoSQL database? NoSQL is notonlySQL

Implement ORM mapping based on Spring Boot and MyBatis Plus Implement ORM mapping based on Spring Boot and MyBatis Plus Jun 22, 2023 pm 09:27 PM

In the development process of Java web applications, ORM (Object-RelationalMapping) mapping technology is used to map relational data in the database to Java objects, making it convenient for developers to access and operate data. SpringBoot, as one of the most popular Java web development frameworks, has provided a way to integrate MyBatis, and MyBatisPlus is an ORM framework extended on the basis of MyBatis.

Build desktop applications using Spring Boot and JavaFX Build desktop applications using Spring Boot and JavaFX Jun 22, 2023 am 10:55 AM

As technology continues to evolve, we can now use different technologies to build desktop applications. SpringBoot and JavaFX are one of the more popular choices now. This article will focus on how to use these two frameworks to build a feature-rich desktop application. 1. Introduction to SpringBoot and JavaFXSpringBoot is a rapid development framework based on the Spring framework. It helps developers quickly build web applications while providing a set of

See all articles