In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "springboot how to use Undertow server", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "springboot how to use Undertow server"!
Display declaration sweep package scope:
That is, instead of using @ SpringBootApplication to scan the package by default, use the ComponentScan annotation to display the declaration to scan the package scope.
@ ComponentScan (basePackages= {"com.xxx.controller", "com.xxx.service"})
The reason is that @ SpringBootApplication scans packages by default, scanning all the subpackages under the startup class. In the actual development scenario, there are many packages that do not need to be scanned, so using the default sweep package will scan a lot of packages that do not need to be scanned in the first place.
When verifying whether there is an optimization effect, if you write your own demo, you cannot verify it, because there are too few packages and classes, so you can verify it with the company's actual project, and it will start much faster.
SpringBoot operation optimization
Use the Undertow server:
By default, SpringBoot uses Tomcat as the embedded servlet container. You can switch the web server to Undertow to improve application performance.
Undertow is a flexible, high-performance web server developed with Java, providing both blocking and NIO-based non-blocking mechanisms. Undertow is Red Hat's open source product and Wildfly's default web server.
Too much is no longer introduced, Baidu knows more.
First remove Tomcat
Org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat
Add Undertow dependency
Org.springframework.boot spring-boot-starter-undertow
Comparison of Tomcat and Undertow throughput (actual test on my computer)
SpringBoot JVM parameter tuning
Set heap parameters according to the memory size of the server.
-Xms: sets the initialization size of the Java stack
-Xmx: sets the maximum java heap size
Instance parameter-XX:+PrintGCDetails-Xmx32M-Xms1M
Local project tuning
External operation tuning
Java-server-Xms32m-Xmx32m-jar springboot_v2.jar thank you for reading, the above is the content of "springboot how to use Undertow server". After the study of this article, I believe you have a deeper understanding of how springboot uses Undertow server, 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.
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.