In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how hot swapping works". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations. I hope you can read carefully and learn something!
Reload static content
Spring Boot has many options for hot loading, but spring-boot-devtools is recommended because it provides other development-time features such as fast application restart and LiveReload, as well as development-time sensitive configuration loading (e.g. template caching).
In addition, IDEs are a good way to develop, especially when debugging is needed (all modern IDEs allow static resources to be reloaded and often support hot swapping of changed Java classes).
Finally, Maven and Gradle plugins also support hot loading of static files from the command line. If you write css/js using other advanced tools and use an external css/js compiler, you can take full advantage of this feature.
Reloading templates without restarting containers
Most templating technologies supported by Spring Boot include a configuration option to disable caching, and if you are using the spring-boot-devtools module, Spring Boot automatically configures those properties for you during development.
Thymeleaf templates
If you are using Thymeleaf, set spring.thymeleaf.cache to false and check Thymeleaf AutoConfiguration for other Thymeleaf customization options.
FreeMarker template
If you are using FreeMarker, set spring.freemarker.cache to false and check FreeMarkerAutoConfiguration for other FreeMarker customization options.
Groovy templates
If you are using Groovy templates, set spring.groovy.template.cache to false and check GroovyTemplateAutoConfiguration for other Groovy customization options.
Velocity templates
If you are using Velocity, set spring.velocity.cache to false and check VelocityAutoConfiguration for other Velocity customization options.
Application Quick Restart
The spring-boot-devtools module includes application auto-restart support, which is not as fast as other technologies, such as JRebel or Spring Loaded, but faster than "cold boot." Before exploring other complex restart options, you'd better try them yourself; for more details, see Using Spring Boot: Developer Tools.
Reloading Java classes without restarting the container
Modern IDEs (Eclipse, IDEA, etc.) all support hot swapping of bytecodes, so if you make a change that doesn't affect the class or method signature, it will reload cleanly and have no impact.
Spring Loaded goes a step further in this respect, it can reload class definitions with method signature changes, and if some custom configuration is made to it can force ApplicationContext to refresh itself (but there is no universal mechanism to ensure that this is always safe for a running application, so it may just be a development-time trick).
Configuring Spring Loaded with Maven
To use Spring Loaded on the Maven command line, you simply add it as a dependency to the Spring Boot plugin declaration, such as:
org.springframework.boot spring-boot-maven-plugin org.springframework springloaded 1.2.0.RELEASE
Under normal circumstances, this works pretty well in Eclipse and IntelliJ IDEA, as long as they have the corresponding build configuration consistent with Maven by default (Eclipse m2e supports this better, out of the box).
Configuring Spring Loaded with Gradle and IntelliJ IDEA
If you want to combine Spring Loaded with Gradle, IntelliJ IDEA, you'll pay a price. By default, IntelliJ IDEA compiles classes to a different location than Gradle, which causes Spring Loaded monitoring to fail.
To configure IntelliJ IDEA correctly, you can use the idea Gradle plugin:
buildscript { repositories { jcenter() } dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE" classpath 'org.springframework:springloaded:1.2.0.RELEASE' }}apply plugin: 'idea'idea { module { inheritOutputDirs = false outputDir = file("$buildDir/classes/main/") }}// ...
Note IntelliJ IDEA must be configured with the same Java version as the command-line Gradle task, and springloaded must be included as a buildscript dependency.
Alternatively, you can enable Make Project Automatically within Intellij IDEA, which automatically compiles whenever a file is saved.
"How does hot swapping work" is introduced here. Thank you for reading it. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.