The DevTools module is a module for developers. The main feature is that the modified code will be automatically reloaded to the server within 5 seconds, equivalent to the restart success. Unlike JRebel, which is a commercial plug-in, DevTools is free.
Devtools: Jrebel is a hot deployment tool for Boot, which reboots the application when we modify classpath files (class files, property files, pages, etc.) (this is very fast due to the dual classloader mechanism, if you find it slow, you can use JRebel) Boot uses two class loaders to implement the restart mechanism: base class loader (BC) and Restart class loader (RC). BC: for loading jars that do not change (eg. Third-party dependent jars) RC: for loading jars that we are developing (eg. We wrote our own classes throughout the project). When the application is restarted, the original RC is discarded and a new RC is created to load the modified items without the BC needing to move. This is why DevTools restarts so quickly.
In the SpringBoot Web project using IDEA, every time the Java file or resource is modified, the project must be restarted, which wastes a lot of time. Then, at this time, it is necessary to realize the hot deployment of the program. The ability to refresh the page immediately when it is modified shows the new effect.
V hot deployment
1.1 Select Build Project Automatically
1.2 Use the shortcut keys Ctrl + Shift + Alt + / to open the Maintenance operation panel and select Registry to open the Registry operation panel
1.3 find and cancel the “compiler. Aut0make. Allow. The when. App. Running”, click Close to Close the operation panel.
1.4 Starting the application and viewing logs.
1.5 Update a class file for verification.
As shown above, spring-boot-DevTools will restart automatically. Note the console logs.
V Hot loading (LiveReload)
2.1 Add LiveReload in Google Store
2.2 Start the project and view the effect
2.3 Effect after update
2.4 Other Methods
In terms of hot loading, if the HTML is updated after startup, direct F5 refresh will also work.
V Source code address
Github.com/toutouge/ja…
About the author: Focus on basic platform project development. If you have any questions or suggestions, please feel free to comment! Copyright notice: The copyright of this article belongs to the author and the blog garden, welcome to reprint, but without the consent of the author must retain this statement, and give the original text link in a prominent place on the page of the article. For the record: all comments and messages will be answered as soon as possible. You are welcome to correct your mistakes and make progress together. Or direct private message I support the blogger: if you think the article is helpful to you, you can click on the lower right corner of the article [recommendation]. Your encouragement is the author to adhere to the original and continuous writing of the biggest power! \