Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of global configuration of Spring Boot DevTools

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the method of global configuration of Spring Boot DevTools". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the method of global configuration of Spring Boot DevTools".

I. the difference between a direct restart project and a devtools restart

After we add the devtools dependency, we can use the first button, while the second button is the button we usually use the most. The biggest difference between the two is that the part of the project that is restarted after modifying the project code is different. The first button (hammer button) is to reload all the changed classes and some user-written code, and will not reload third-party plug-ins and dependencies as well as libraries, which saves time. But the second button will reload all the resources of the project, which is a waste of cpu resources; so our developers usually use devtools to assist in development.

II. Configure org.springframework.boot spring-boot-devtools runtime true for DevTools

As long as the code is modified, clicking the compile button (green hammer) will restart the project, reload all changed classes and some user-written code, and will not reload third-party plug-ins and dependencies and libraries

III. Global configuration of DevTools

Create a new file named .spring-boot-devtools.properties under the current user's directory of the system, in which you can write the configuration of devtools in application.properties, but unlike application.properties, the global configuration file is loaded by all started projects, while application.properties is loaded only by this project.

4. Trigger-file controls restart behavior 4.1, configuration

Choose one of the following, the former project configuration and the latter global configuration

Application.properties configuration

Spring.devtools.restart.trigger-file=.reloadtrigger

.spring-boot-devtools.properties configuration

Spring.devtools.restart.trigger-file=.reloadtrigger4.2, new file. Reloadtrigger

Fill in some characters at random in the document

4.3.Test class @ RestControllerpublic class HelloController {@ GetMapping ("/ hello") public String getdev () {return "hello devtools 123";}} 4.4.Control restart Controller class

.reloadtrigger file

Request http://localhost:8080/hello

After that, we modify the Controller code, but we do not modify the .reloadtrigger file

@ RestControllerpublic class HelloController {@ GetMapping ("/ hello") public String getdev () {return "hello devtools 1234";}}

After recompilation:

The result remains the same.

We will now modify the .reloadtrigger file

Recompile:

The project is restarted and updated to generate the modified code

Thank you for reading, the above is the content of "the method of global configuration of Spring Boot DevTools". After the study of this article, I believe you have a deeper understanding of the method of global configuration of Spring Boot DevTools, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report