Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to realize the hot deployment of the project in SpringBoot

Shulou Source: shulou.com Published: 2022-06-01 18:46:14 11月15日 Update

This article shows you how to achieve the hot deployment of the project in SpringBoot, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The principle of hot deployment

The principle is that the implementation principle of hot deployment mainly depends on the class loading mechanism of java. The implementation method can be summarized as a background thread when the container starts to detect the change of the timestamp of the class file regularly. If the timestamp of the class changes, then reload the class file of the entire application, restart the service and redeploy at the same time.

Automatically deploy file changes to the server and restart the server automatically. Developers can reload changes on the Spring Boot without restarting the server. This eliminates the need to deploy changes manually each time.

Implementation of hot deployment

1. Add dependencies

Org.springframework.boot

Spring-boot-devtools

True

2. Add plug-ins

Org.springframework.boot

Spring-boot-maven-plugin

True

True

3. Configure in yml file to enable hot deployment

Spring:

Devtools:

Restart:

Enabled: true

4. Idea settings

Settings-- > Compiler-- > check Build project automatically

5. Set running in Registry

Use shift+ctrl+alt+ "/" (shortcut key in IDEA) to select "Registry" and then select compiler.automake.allow.when.app.running

The above is how to implement the hot deployment of the project in SpringBoot. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Files services principles servers projects content skills time knowledge concise concise people at the same time background containers that is keyboard shortcuts manual plug-ins articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux macOS Redmi MariaDB