Oh my god! ! The 24-year-old Meituan 80W annual salary architect finally compiled and shared the SprinBoot programming thought document, hurry up and read it, hurry up and learn! !

Preface

At the age of 24, some people may have just found a job and are working silently; some people, in order to live in Bei Piao, make unremitting efforts for rent; some people may not have a direction yet, are in a confused stage, and are at a loss!

And he, 24, is already an 80W annual salary architect of Meituan. What the hell is this for?

Because he has loved programming since he was a child. He has been in love with programming since he was 13 years old. Through his unremitting efforts, he has finally been admitted to the university he dreamed of, and his studies have always been among the best!

Finally, I applied for Ali in the year of graduation. With his excellent source code foundation and rich architectural thinking, he completely conquered Ali's p9 interviewer and successfully got Ali's p6 rank and p7 salary. Later, he moved to the United States. The group got 80W annual salary + stocks.

Occasionally, when there was an opportunity to talk, I asked him why he has such a high achievement? He told me about his experience, so he talked a lot with me. I was really impressed by his thinking and technical ability, and I was older than him, so ashamed! !

Later, he recommended a document to me. At the beginning, I didn’t care and didn’t read it seriously. When I calmed down and wanted to learn, I suddenly remembered this document, so I picked it up and read it carefully. , As expected, the architectural thinking is really strong! !
Let my life embark on a bright path from now on!

Today I have the honor to share this springboot programming thought document with you. I hope you can read the truth carefully, and I hope you can like it! !

table of Contents

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

main content

This article begins with an overview of the core features of Spring Boot and discusses the six features listed on the Spring Boot official website one by one. However, two of them are not exclusive to Spring Boot, so we will stop here. The discussion will focus on its five features, namely Auto-assembly (Auto- Configuration), SpringApplication, externalized configuration, Spring Boot Actuator and embedded Web container.

Part 1 Overview of Spring Boot

Chapter 1 A First Look at Spring Boot; 1.1 Spring Framework Era, 1.2 Introduction to Spring Boot, 1.3 Features of Spring Boot, 1.4 Ready to Run Environment;

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 2 understands independent Spring applications; verbally, developers often refer to applications built by the Spring Boot framework as Spring Boot applications, but they are actually Spring applications. Among the above-mentioned web containers, neither the Servlet container nor the Netty web container belong to the Spring family of products.

In traditional Spring applications, the external container needs a startup script to boot it, and executes the initialization of the Spring context with its life cycle callback. The more representative ones are the ContextLoaderListener in Spring Web and the DispatcherServlet in Web MVC. The former uses the servletContext life cycle to build the Web ROOT Spring application context, and the latter combines the Servlet life cycle to create the Spring application context of the DispatcherServlet. Either way, it belongs to passive callback execution, which is why they do not have complete application dominance. However, when the embedded container startup mode appears in Spring Boot, the embedded container becomes part of the application. In essence, it belongs to the component Beans in the Spring application context. These components and other components are assembled into Spring Beans by auto-assembly features. Definition (BeanDefinition), registered and initialized with the startup of the Spring application context. The core component that drives the startup of the Spring application context is the SpringBoot core API SpringApplication, so it is a Spring application, which can also be called a Spring Boot application.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 3 understands the solidified Maven dependencies; in the previous discussion, related Statuser dependencies were introduced, such as org.springframework.boot:spring-boot-starter-web, org.springframework.boot:spring-boot-loader also in this way. It is also known that the version information of both are inherited from org.springframework.boot:spring-boot-starter-parent, and these features belong to the scope of Maven dependency management, which reduces the cost of Spring Boot application management dependency. Therefore, Spring The official description of Boot is "We take an opinionated view of the Spring platform and third-party libraries so you can getstarted with minimum fuss.". However, there are certain limitations by configuring org.springframework.boot:spring-boot-starter-parent. Because of the single-inheritance approach, it limits its solidification of Maven dependencies (only Spring Boot related), and it is very likely to be applied pom.xml has a custom Parent. If you need to solidify other types of dependencies, it is more troublesome, such as Spring Cloud dependencies. The official Spring Boot document has relevant instructions in the chapter "13.2.2 Using Spring Boot without the ParentPOM":

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 4 Understanding Embedding Web Containers; On the official Spring Boot web page, developers are clearly reminded that Spring Boot applications directly embed Tomcat, Jetty and Undertow as its core features, and there is no mention of embedded Netty Web Server, which may be due to the current Spring Boot 1.x and 2.0 coexist, while the embedded Netty Web Server is only a new feature of version 2.0. These types of container implementations are collectively referred to as embedded Web containers, and containers are mutually exclusive and cannot coexist. However, the Spring Boot project can switch the embedded container type of the Spring Boot application by specifying the Maven dependency of the container. There is no need to adjust the code level. Different embedded containers have exclusive configuration properties, and naturally they no longer need to be deployed in the form of WAR files. :

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 5 understands automatic assembly; automatic assembly is a prerequisite, it depends on the JAR file dependency added by the developer under the application’s Class Path, and the entity of its automatic assembly is not necessarily loaded, so the document uses "attempts" (try ) To describe.

When HSQLDB exists in the application's Class Path, developers do not need to manually configure the Beans connected to the database, but a memory-based database is automatically assembled by Spring Boot. However, the official description of the example of automatic assembly in such an understatement may cause confusion. It can be understood that the object of Spring Boot's automatic assembly is Spring Bean, so manual intervention is not required, such as assembling the Bean through XML configuration files or Java coding. Obviously, the official believes that developers should know HSQLDB. Similarly, it also believes that Spring Boot users are familiar with Spring Framework.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 6 understands the Production-Ready feature; as one of the core features of Spring Boot, such a brief explanation will inevitably cause confusion, but the Production-Ready concept has achieved a preconceived effect. For this reason, I have also checked a lot of information about the interpretation of the term "Production-Ready". For example, searching for the keyword "Production-Ready" from Google, I was surprised to find that the first page of the search result did not appear in any Spring-related content.

The first three search results are:

  • .Define "production-ready" - Software Engineering Stack Exchange
  • .What does it mean when code is 'production ready? - Quora
  • What does it mean to be "production ready"?- Issue #3 - mitodl…

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Part 2 is towards automatic assembly;

Chapter 7 Towards Annotation-Driven Programming (Annotation-Driven); I believe that most senior developers must understand two core ideas before officially using Spring Framework: loC (Inversion of Control, Inversion of Control) and DI (Dependency Inject) , Dependency Injection), its advocating concept is that application systems should not directly control dependencies in the form of Java code, but manage them through containers. Then the author of Spring Framework explained the naturalness of its framework for IoC and DI support. Since Java 5Annotation had not yet been released at that time, combined with the tradition of J2EE (the predecessor of JavaEE, also known as J2EE at the time), the dependency between Beans was managed by way of XML files.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 8 Spring annotation-driven design pattern; 8.1 Spring @Enable module driven; 8.2 Spring Web automatic assembly; 8.3 Spring conditional assembly.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 9 Spring Boot Auto-Assembly; Obviously, before auto-assembling ProxyAsyncConfiguration, it is necessary to conditionally judge the meta-annotation of @EnableAsync. Looking at the essence through the phenomenon, when a Spring application automatically assembles certain components, it needs a comprehensive technical means to deeply integrate Spring Framework's native features such as the Spring annotation programming model, @Enable module driver, and conditional assembly. This technology is "Spring Boot autowiring".

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Part 3 understand SpringApplication;

Chapter 10 SpringApplication initialization phase; The SpringApplication initialization phase belongs to the pre-run preparation phase. Most Spring Boot applications directly or indirectly use SpringApplicationAPI to drive Spring applications. SpringApplication allows you to specify the type of application, which generally includes web applications and non-web applications. Starting from Spring Boot 2.0, Web applications can be divided into Servlet Web and ReactiveWeb. Of course, SpringApplication can also adjust the output of Banner, configure the content of default properties, etc. These state change operations only need to be specified before the run() method. Simply put, the preparation phase of SpringApplication is mainly completed by two phases: the construction phase and the configuration phase. Next, we will discuss in depth.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 11 SpringApplication runtime phase; SpringApplication runtime phase belongs to the core process, which is fully developed around the run(String...) method. This process, combined with the completed state of the initialization phase, further improves the resources that need to be prepared at runtime, and then starts the Spring application context. During this period, with the triggering of Spring Boot and Spring events, a complete Spring Application life cycle is formed. Therefore, the following discussion will focus on the following three sub-topics:

  • SpringApplication preparation phase;
  • ApplicationContext startup phase;
  • .ApplicationContext post-launch phase.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 12 SpringApplication End Phase; Spring Boot 1.x and 2.0 versions are relatively stable for the implementation logic of SpringApplication end phase, and there are two situations where SpringApplication ends normally and SpringApplication ends abnormally. However, in terms of implementation methods, there are indeed differences between the previous version and the previous version, which will be discussed below.

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

Chapter 13 Spring Boot application exit; according to its literal meaning, when the execution of the Spring Boot program ends, the ExitCodeGenerator Bean will return the exit code implemented by the getExitCode() method, but this also implies a precondition, that is, the Spring application context must be Active (the ConfigurableApplicationContext#isActive() method returns true), indicating that the SpringApplication ends normally at this time. On the contrary, when SpringApplication runs abnormally, how does the exit code affect the behavior of Spring Boot applications?

The 24-year-old Meituan 80W annual salary architect shares SprinBoot programming thought documents

 

This [springboot programming thought core article] has a total of 628 pages, because the content is too much to show everyone one by one, friends who need the full version, can forward this article to follow the editor, scan the code to get it! !

to sum up

This article uses Spring Boot 2.0 as the main thread of discussion, and the scope of discussion will cover all versions of Spring Boot 1.x and the associated Spring Framework version, focusing on:

  • ·Scene analysis-master technology selection
  • ·Systematic learning-refuse to taste
  • ·Pay attention to norms-understand the development trend
  • ·Source code interpretation-understanding design ideas
  • ·Practical drills-consolidate learning achievements

I hope this article can help you learn, let you quickly master the technical knowledge, enhance your own technical depth and breadth, make yourself more valuable, and hope to be liked by everyone! !

Guess you like

Origin blog.csdn.net/qq_1813353297/article/details/109250709