I TM kneel! The 80W Meituan architect even sorted out and shared Spring5 enterprise-level development practical notes

Preface

Spring, as an essential framework for Internet companies, was created by Rod Johnson.

It was created to solve the complexity of enterprise application development and provide a one-stopshop solution for applications.

The development of Spring is changing with each passing day, and it has evolved to the stage of 5.0. In addition to thoroughly introducing the Spring standard modules, this article shows the readers the new features of 5.0 in a detailed manner. The examples are also very refined. In addition, Spring is integrated with other modules. The rapid experience of the game is also actual combat, which provides a good guide for readers to quickly land in actual combat.

This article describes the various important core technologies and the latest practical technologies in the actual development and application scenarios of Spring 5, and discusses the application scenarios of each technology in a simple and simple way. The explanation is in-depth and easy to understand. It is not only suitable for beginners to systematically learn Spring technology, but also suitable for people with certain work experience to strengthen and deepen their understanding of Spring. It is a high-quality Spring technology good article.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

This article will introduce to you from the table of contents, the specific chapters contained in the main content, and the summary. I hope you can read it carefully and absorb it, and I hope you will like it! !

table of Contents

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

 

 

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

main content

The full text contains a total of three parts, 19 chapters and an appendix. The specific content will be introduced next:

The first Spring basics;

Chapter 1 Environment Construction; This chapter mainly introduces the composition of the Spring technology system, and preliminarily explains the installation and use of some development tools needed to build the Spring project. Build a simple Spring MVC project through Spring, and then access the HTTP interface provided by the Spring MVC project through a browser to print text, such as Hello World. The next chapter will explain the core concept of the Spring framework-loC.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 2 Spring loC container principle;

This chapter mainly introduces one of the core concepts of the Spring framework-loC, and explains the implementation of loC through a case. Starting from the Spring code, it analyzes the startup process of the Spring loC container, and explains the Bean in the Spring loC container through a case. So far, the Spring core loC analysis is completed. The next chapter will explain another core concept of the Spring framework-AOP.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 3 Secrets of Spring AOP;

This chapter explains the use of Spring's core function AOP, and through the analysis of the code, reveals the realization principle of JDK dynamic proxy and CGLIB dynamic proxy. The next chapter will introduce the new features of Spring 5.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

The second part is the advanced features of Spring 5;

Chapter 4 Overview of New Features of Spring 5;

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 5 Overview of the new features of Java 8;

This chapter mainly introduces the important new features of Java 8. We will use it in Spring 5 programming and creating projects. I hope you can understand and master them.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 6 Spring WebFlux Reactive Programming;

This chapter explains Spring WebFlux reactive programming, which is the new feature of Spring 5. WebFlux can be used as an alternative to Spring MVC to implement programming in an asynchronous and non-blocking manner to improve system performance. Spring WebFlux relies on Reactor. Section 6.3 of this chapter introduces some introductory knowledge of Reactor. For more advanced features of Reactor, please refer to the official website of Reactor.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 7 WebClient Responsive Client;

This chapter introduces the client tool WebClient used with Spring WebFlux, compares the use of RestTemplate and WebClient, and introduces some common methods related to Http requests using WebClient. By using WebFlux, it is more convenient to run and debug WebFlux responsive programming.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 8 Spring 5 combined with Kotlin programming;

Kotlin allows developers to use simple and elegant code to achieve the same functions as Java, while providing interoperability with existing Java class libraries. The Spring framework provides Kotlin support, making it easy for Java development to use Kotlin, and it also allows Kotlin developers to seamlessly use the Spring framework.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 9 Spring 5 more new features;

Spring 5's support for HTTP/2 and Junit 5 will bring developers a better user experience and improve their development efficiency.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

The third part is the Spring system integration chapter,

Chapter 10 Spring integrates Log4j2;

This chapter introduces the principle of using SLF4J and Log4j2 together, and introduces the relevant knowledge of facade design patterns. For more knowledge about design patterns, please refer to the appendix of this book.

The actual combat exercise in section 10.3 of this chapter introduces the configuration of Log4j2 in common enterprise development. Readers can apply the configuration to their own production practice, output richer system running logs, and provide better monitoring system stability. Protection.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 11 Spring integrates Spring MVC;

Spring MVC is the most used web-layer framework in the enterprise development process. Spring MVC is often asked in interviews, and most of the interview questions focus on the underlying principles of Spring MVC and the learning of Spring MVC code. Therefore, the analysis of Spring MVC code in this chapter is very necessary.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 12 Spring integrates MyBatis;

MyBatis is one of the most commonly used ORM frameworks in enterprise development. This chapter explains a common scenario of using MyBatis in enterprise development through the integration of MyBatis with Spring and Spring MVC; and explains the operating principle of MyBatis through the analysis of the underlying code of MyBatis.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 13 Spring transaction management;

Spring transaction management is a commonly used technology in enterprise development. Understanding the code of Spring transaction management is of great help to understanding Spring transaction management. The Spring transaction isolation level, Spring transaction propagation behavior and Spring transaction code analysis involved in this chapter are all common interview questions, and I hope readers must master them.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 14 Spring integrates Redis;

Redis is an open source Key-Value database that is written in ANSIC language, supports the network, and can be based on memory and can be persisted.

Redis usually acts as a cache in enterprise development to protect interfaces or databases. It can also act as a distributed lock in high concurrency scenarios and distributed scenarios, avoiding multiple JVM processes from modifying the same resource at the same time, resulting in inconsistent data.

Because Redis is the most commonly used caching technology in development, this chapter will focus on the analysis of Redis common operation commands and Redis common architecture and the integrated development of Spring and Redis.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 15 Spring integrates ZooKeeper;

ZooKeeper is an open-code distributed coordination service framework and a component that provides consistent services for distributed applications. Coordinating and managing services in a distributed environment is a very complex process. ZooKeeper solves this problem through its simple architecture and API. ZooKeeper allows developers to focus on the core application logic without worrying about the distributed nature of the application.

This chapter explains the deployment of ZooKeeper clusters and the integrated development of Spring and ZooKeeper. ZooKeeper is a commonly used distributed coordination service in enterprise development. Proficiency in using ZooKeeper is of great help to system decoupling and system high availability in a distributed environment.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 16 Spring integrates Kafka;

Kafka is an open source stream processing platform developed by the Apache Software Foundation, written in Scala and Java. Kafka is a high-throughput distributed publish-subscribe messaging system. Kafka has high performance, durability, multi-copy backup, and horizontal expansion capabilities. The producer writes a message to the queue, and the consumer fetches the message from the queue for business logic. Generally play the role of decoupling, peak cutting, and asynchronous processing in enterprise architecture design.

Kafka plays a very important role in enterprise development. Common usage scenarios are as follows.
(1) Log collection. In enterprise development, Kafka can be used to collect logs of various services and open to various consumers through Kafka in a unified interface service, such as Hadoop, Hbase, and Solr.

(2) Message system. Decoupling producers and consumers is often used to decouple payment or order scenarios.

(3) User behavior tracking. Kafka can be used to record various behaviors of Web users or App users, such as web browsing, product retrieval, and "clicks". These activity information is published by each server to the Topic corresponding to Kafka, and then subscribers can subscribe to these Topic for real-time monitoring and analysis, or load it into Hadoop or data warehouse for offline analysis and mining.

(4) Kafka is also often used to record operation and maintenance monitoring data. Including collecting data from various distributed applications and producing centralized feedback for various operations, such as alarms and reports.

(5) Streaming processing. Such as Spark Streaming and Storm.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 17 Spring integrates Mycat;

Mycat hides the details of sub-database and sub-table. From the perspective of the developer, the application can operate the database without knowing which sub-table of which library is operated. For some old projects, the introduction of Mycat to sub-database and table, no need to modify the business code, only need to modify the JDBC connection to achieve the project upgrade.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 18 Spring integrates Sharding-JDBC;

Sharding-JDBC is an open source database middleware. Sharding-JDBC is positioned as a lightweight database driver. The client directly connects to the database and provides services in the form of jar packages. There is no intermediate layer, no additional deployment, and no other dependencies. Sharding-JDBC can achieve the goal of zero cost for old code migration . Sharding-JDBC is different from .MyCat, MyCat is essentially a database proxy.

Sharding-JDBC is similar to Mycat, both of which are middleware for sub-databases and tables. Mycat provides database services in the form of a proxy, which is completely transparent to applications. Sharding-JDBC uses the JDBC protocol layer to expand the sub-database and sub-table. It is a lightweight component that provides services in the form of a jar package. Readers can choose to use the appropriate sub-library and sub-table components according to specific scenarios.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Chapter 19 Spring integrates Dubbo;

Dubbo is a high-performance and excellent service framework open sourced by Alibaba. Dubboo enables applications to implement service output and input functions through high-performance RPC, and can be seamlessly integrated with the Spring framework.

Dubbo is a powerful tool for the development of microservices by Internet companies, and mastering Dubbo is of great significance to the evolution and upgrade of enterprise microservice architecture.

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Appendix A design patterns,

Design pattern (Design pattern) is the best practice in the field of software engineering. The Spring code analysis part explained in this article involves a large number of design patterns. Design patterns are often asked in interviews. Design patterns are not superb techniques, but are summed up by many software developers after a long period of trial and error correction.

A.1 Factory model

Factory Pattern (Factory Pattern) is one of the most commonly used design patterns in Spring. The factory pattern is a creational pattern, which provides the best way to create objects. In the factory pattern, the logic of creating an object is hidden, and a common interface is used for the caller to use.

A.2 Abstract factory pattern

The abstract factory revolves around a super factory to create other factories. In the abstract factory pattern, the interface is responsible for creating a factory of related objects without explicitly specifying their types. Each factory generated from the abstract factory can provide objects in accordance with the factory pattern.

A.3 Singleton mode

The singleton pattern involves a single class that is responsible for creating its own objects while ensuring that only a single object of this class is created. Spring managed beans are singletons by default.

A.4 Builder Mode

The builder mode builds multiple simple objects into one complex object. A Builder class will construct the final object step by step. The Builder class is independent of other objects.

Assuming the following scenario, each computer consists of a CPU and a monitor. Nowadays, the common manufacturers of CPU are Intel and AMD, and the common manufacturers of display are DELL and PHILIPS. Each computer consists of a CPU and monitor.

A.5 Prototype mode

The prototype mode is used to create repeated objects. This mode implements a prototype interface that is used to create a clone of the current object. When the cost of creating an object is high, this design pattern is more suitable. If creating an object requires expensive database operations and remote calls, then the object can be cached. When the next request comes, the cloned object of the object is returned, and the object is cached when needed to reduce database calls and remote calls.

A.6 Adapter Mode

The adapter mode serves as a bridge before incompatible interfaces. The adapter pattern involves a class that is responsible for adding independent or incompatible interface functions.

The following example demonstrates the use of adapter mode. Among them, the audio player can only play MP3 format files, and the video player can play MP4 format files and RMVB format files. Now want to use the adapter mode to make the audio player not only play MP3 format files, but also other formats.

A.7 Bridge Mode

If there are two independent changing dimensions for a certain class in a software system, these two dimensions can be separated through the bridge mode, so that the two can be expanded independently, and the system is more in line with the "single responsibility principle". Different from the multi-layer inheritance scheme, the bridging model designs two independent and changing dimensions as two independent inheritance structures, and establishes an abstract association at the abstract layer, which is similar to a bridge connecting two independent inheritance structures, so it is called For bridge mode.

A.8 Standard Mode

Standard mode allows developers to use different criteria to filter a set of objects. Standard mode can combine multiple criteria to obtain a single standard.

A.9 Combination mode

Combination mode is a mode that treats a group of related objects as a single object. The combination mode combines objects according to a tree structure, which is used to represent part and overall levels.

A.10 Decorator Mode

The decorator mode adds new functions to existing objects without destroying the structure of the object. Use the decorator pattern to create a decoration class to wrap the original class.

A.11 Appearance mode

The appearance mode hides the complexity of the system and provides a unified high-level access interface for a group of interfaces in the subsystem. This interface makes the subsystem easier to access or use. The advantage of the appearance mode is that it is convenient for users to use, it combines the excessively divided and dispersed functions into a whole, provides a unified interface to the outside, and hides the underlying implementation.

Taking the hospital as an example, the hospital is regarded as a system. According to the functions of the departments, the system can be divided into departments such as registration, outpatient service, laboratory testing, payment, and medicine collection. The patient has to deal with these departments, just as the client of a system deals with different classes of a system. The client needs to process a lot of logic to determine when a certain class should be called.

A.12 Flyweight model

Flyweight mode mainly reduces the number of objects created to achieve the purpose of improving performance. Flyweight mode tries to reuse existing objects of the same kind, and if the existing objects do not match, create new objects.

A.13 Agency mode

The proxy mode uses one class to represent the function of another class, and access to this object can be controlled through the proxy.

A.14 Chain of Responsibility Model

The chain of responsibility pattern creates a series of processing objects for the request, and these processing objects form a chain. The responsibility model decouples the sender of the request and the processing object. In this mode, if a processing object cannot process the request, the processing object will pass the same request to the next receiver, and so on. The usage scenarios of the chain of responsibility include interceptors in Struts and filters in Servlet.

A.15 Command mode

Command mode is a data-driven design mode. The command mode request will be encapsulated in the object in the form of a command and passed to the calling object. The calling object will find a suitable object that can process the command and pass the command to the corresponding processing object for processing.

A.16 Interpreter mode

The interpreter mode provides the function of parsing grammar or expressions. The interpreter mode is used in SQL parsing, symbol processing engines, etc.

A.17 Iterator mode

The iterator pattern is a commonly used design pattern in the JDK. Using this mode will sequentially access the elements of the collection object, without knowing the underlying storage of the collection object.

A.18 Intermediary model

The intermediary model is usually used to reduce the complexity of communication between multiple objects. The intermediary pattern provides an intermediary class, which handles the communication between different objects and maintains loose coupling between multiple objects, making the code easy to maintain.

A.19 Memo mode

The memo mode is used to save the state of an object so that the object can be restored at an appropriate time. The memo mode captures the internal state of an object without destroying the encapsulation, and saves this state outside the object, so that the object can be restored to the original state in the future.

A.20 Observer Mode

When there is a one-to-many relationship between objects, the observer mode is used. The main function of the observer mode is that when the state of an object changes, all objects that depend on it are notified and automatically updated.

A.21 State mode

In the state mode, the behavior of the class is based on the state change. You can create objects representing various states and a Context object whose behavior changes as the state object changes.

A.22 Null Object Mode

In the empty object mode, an empty object is used instead of null. Null objects can strengthen the stability of the system, can effectively prevent the impact of null pointer errors on the entire system, and make the system more stable.

A.23 Strategy mode

The strategy mode defines a series of algorithms, and encapsulates each algorithm so that each algorithm can replace each other, separates the algorithm and the client using the algorithm, and is independent of each other.

A.24 Template mode

The template pattern defines the skeleton of an algorithm, which can delay some specific steps to subclasses. The template method allows subclasses to redefine certain specific steps of an algorithm without changing the structure of the algorithm.

A.25 Intercept filter mode

The interception filter mode is used to do a series of processing on the request or response. The filter can do authentication/authorization/logging, or track the request, and then pass the request to the corresponding processing program.

Comes with 23 kinds of design pattern video tutorials:

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

Bundled with spring source video + interview questions + documents:

80W Meituan architects compiled and shared Spring5 enterprise-level development actual documents

 

to sum up

This article is highly recommended by 13 experts!

The full text combines theory and engineering practice to comprehensively explain the new features of Spring5; from Spring actual combat to source code analysis, to principle analysis, and the practice of combining Spring with various mainstream middleware and frameworks, readers can deeply understand the implementation of Spring. Principle and underlying architecture, use Spring's powerful functions to build complex Spring applications top-down.

Friends who need this 543-page [Spring5 enterprise-level development combat] document, [spring source video + interview questions + document], [23 design pattern tutorial video], can forward this article and follow the editor, scan the code below to get ! ! !

Guess you like

Origin blog.csdn.net/bjmashibing001/article/details/111215406