SpringBoot summary article

        Today, SpringBoot series also came to a close, recall the original scene flag stand, as if still fresh in our memory. With the completion of a month and organized into SpringBoot article? And set up some fantastic plans, so I thought at the time. However, although the process is difficult, but the ending is pretty perfect, complete moment in the last article, the mood is very calm, I think, is probably accustomed to it.

        At the end of the series, and then the SpringBoot make a summary, it can be considered the dust settles.

text

        SpringBoot most notable feature is the Quick Start a Spring application, provides more extensive support for all the features Spring; provide universal non-functional features a series of large-scale projects (such as the embedded server, security, index, and external health check Disposition); no code generation, XML configuration does not need is a highlight.

Although this series of articles to discuss SpringBoot as the center, but also related to the Spring technology stack, because that is the underlying core SpringBoot Spring, Spring if well aware that learning SpringBoot downhill.

1, automatic assembly base

See "SpringBoot (a) assembling a basic automatic"

SpringBoot in a lot of use Spring annotations, notes that roughly divided into these categories:

  1. Configuration Notes: @ Configuration, @ ComponentScan, @ Import, @ Conditional, Bean
  2. Mode Notes: @ Componnt, @ Repository, @ Service, @ Controller
  3. @Enable 模块注解:@EnableWebMvc、@EnableTransactionManagement、@EnableWebFlux

Configuration notes are carried out in the Spring of ConfigurationClassParser # doProcessConfigurationClass method of treatment, follow-up will be described in detail in Spring series of articles; mode notes are marked @Component notes, are derived @Component notes, @ ComponentScan scans the label @Componentand its derived annotations class and added to these classes Spring container; @Enablemodule annotated by @Importimporting configuration class, the configuration of these classes loaded @Enablecomponent modules required.

2, automatic assembly body

See "SpringBoot (II) autowiring text"

At SpringBoottimes, by a main method you can start an application that is dependent on the underlying Springfew notes. From the @SpringBootApplicationannotation of @EnableAutoConfigurationstarts annotation, @EnableAutoConfigurationbelonging to Springthe @Enablemodule annotated by the annotation @Importintroduced AutoConfigurationImportSelectorclasses, all in the class to be loaded AutoConfigurationas denoted by a suffix and @Configurationautomatically configured based annotations, each class may be equipped to automatically configure an external module, such as Web MVC module corresponding configuration class is WebMvcAutoConfiguration. In another class of the many autoconfiguration @Conditionalconditions annotation can achieve flexible assembly.

3, SpringApplication startup class preparation phase

See "SpringBoot (three) SpringApplication start class preparation phase"

In the construction SpringApplicationstartup class, initialize several important categories, such as WebApplicationType, ApplicationContextInitializer, ApplicationListener. Where WebApplicationTypestorage is the current application type, such as Servlet Web, Reactive Web; ApplicationContextInitializerand ApplicationListenerare SpringBootcreated by extending the Spring features initializer and listeners.

4, SpringApplication startup class operational phase

See "SpringBoot (four) SpringApplication class start running phase"

In the SpringApplicationoperating phase, first by extension Spring, monitoring mechanisms in SpringBootpublishing various stages of different events, perform multiple event listeners; then create a Environmentclass, which is outside of the core class configuration; and finally start Springcontainer, by WebApplicationTypejudging the current application type, create applications corresponding to ApplicationContextapplication context, and then call the ApplicationContext#refreshmethod starting container.

5, the outer configuration of the Environment

See "SpringBoot (e) of the external configuration of the Environment"

This article describes several types of resources outside of configurations, such as properties, YAML, environment variables, system properties, startup parameters. Also details the Environmentclass, which is an external configuration of core classes, all externalize configuration data are stored in the class, and storage and we discussed the whole process.

6, the external configuration of @ConfigurationProperties

See "SpringBoot (f) of the external configuration of @ConfigurationProperties"

@ConfigurationPropertiesIt is SpringBootimportant to realize external annotation of configurations, with SprinBootautomated assembly features to achieve rapid development. The main configuration file and the properties in the Properties configuration class attribute mapping, and we also discussed the entire mapping process.

7, Embedded Web container

See "SpringBoot (seven) Embedded Web Container"

This article discusses the creation and launch container. Traditional Springapplications need to manually create and launch a Web container, in SpringBoot, the way it is embedded automatically create and start. SpringBootWeb container types are supported, and the Servlet container Reactive Web Web container, which container has a specific realization, a corresponding Web Sevlet Tomcat, , Jetty, Undertowdefault implementation Tomcat; Reactive Web corresponds Netty.

8, Custom Starter Starter Mechanism

See "Custom Starter (eight) Starter Mechanism SpringBoot"

This article describes in detail SpringBootthe Startermechanism, and by custom Starterto deeply understand the whole operation mechanism. StarterAlso SpringBootimportant characteristics, by integrating Starterrely, to simplify the development process and build the project.

Epilogue

Summary article on the end here, finally, rivers and lakes road is long, we, see the next series.

Guess you like

Origin www.cnblogs.com/loongk/p/12164334.html