Reasons for choosing an embedded container for spring boot projects

Spring boot is a new framework provided by pivot team. It is designed to simplify the initial construction and development process of new spring applications. The framework uses a specific way to configure, so that developers no longer need to define templated configurations. In this way, spring boot is committed to becoming a leader in the booming field of rapid application development.

Spring boot inherits the advantages of spring and adds some new functions and features:

(1) Springboot was born with spring 4.0. Once it was launched, it caused a huge reverse;

(2) Literally, boot means boot, so springboot helps developers quickly build the spring framework;

(3) Springboot helps developers quickly start a web container;

(4) Springboot inherits the excellent gene of the original spring framework;

(5) Springboot simplifies the process of using spring;

(6) Spring boot has brought us the efficiency of script language development, but spring boot has not surprised us. It is a common technology for Java EE developers.

The default web container of spring boot project is tomcat, but developers can modify it as needed. For example, using jetty or undertow, spring boot provides the corresponding starters.

How Do

Jetty container startup

PS: if you use gradle, you can refer to the official document - use jetty instead of Tomcat

analysis

The reason for supporting the above switching is the automatic configuration of spring boot. I first exclude the Tomcat dependency from the spring boot starter web dependency to avoid the dependency conflict with jetty. Spring boot determines which web container to use according to the type of container class scanned under the classpath.

View the internal structure of embeddedservletcontainerautoconfiguration class in idea, and you can see @ H_ 301_ 71 @ @ conditionalonclass ({servlet. Class, server. Class, loader. Class, webappcontext. Class}) matches the annotation. If you can find instances of the above three classes in jetty's jar package, you decide to use jetty container.

Similarly, we can see that there are similar judgment and use codes for Tomcat:

summary

The above is the embedded container of spring boot project introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>