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:
- Configuration Notes: @ Configuration, @ ComponentScan, @ Import, @ Conditional, Bean
- Mode Notes: @ Componnt, @ Repository, @ Service, @ Controller
- @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 @Component
and its derived annotations class and added to these classes Spring container; @Enable
module annotated by @Import
importing configuration class, the configuration of these classes loaded @Enable
component modules required.
2, automatic assembly body
See "SpringBoot (II) autowiring text"
At SpringBoot
times, by a main method you can start an application that is dependent on the underlying Spring
few notes. From the @SpringBootApplication
annotation of @EnableAutoConfiguration
starts annotation, @EnableAutoConfiguration
belonging to Spring
the @Enable
module annotated by the annotation @Import
introduced AutoConfigurationImportSelector
classes, all in the class to be loaded AutoConfiguration
as denoted by a suffix and @Configuration
automatically 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 @Conditional
conditions annotation can achieve flexible assembly.
3, SpringApplication startup class preparation phase
See "SpringBoot (three) SpringApplication start class preparation phase"
In the construction SpringApplication
startup class, initialize several important categories, such as WebApplicationType
, ApplicationContextInitializer
, ApplicationListener
. Where WebApplicationType
storage is the current application type, such as Servlet Web, Reactive Web; ApplicationContextInitializer
and ApplicationListener
are SpringBoot
created by extending the Spring features initializer and listeners.
4, SpringApplication startup class operational phase
See "SpringBoot (four) SpringApplication class start running phase"
In the SpringApplication
operating phase, first by extension Spring
, monitoring mechanisms in SpringBoot
publishing various stages of different events, perform multiple event listeners; then create a Environment
class, which is outside of the core class configuration; and finally start Spring
container, by WebApplicationType
judging the current application type, create applications corresponding to ApplicationContext
application context, and then call the ApplicationContext#refresh
method 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 Environment
class, 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"
@ConfigurationProperties
It is SpringBoot
important to realize external annotation of configurations, with SprinBoot
automated 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 Spring
applications need to manually create and launch a Web container, in SpringBoot
, the way it is embedded automatically create and start. SpringBoot
Web container types are supported, and the Servlet container Reactive Web Web container, which container has a specific realization, a corresponding Web Sevlet Tomcat
, , Jetty
, Undertow
default implementation Tomcat
; Reactive Web corresponds Netty
.
8, Custom Starter Starter Mechanism
See "Custom Starter (eight) Starter Mechanism SpringBoot"
This article describes in detail SpringBoot
the Starter
mechanism, and by custom Starter
to deeply understand the whole operation mechanism. Starter
Also SpringBoot
important characteristics, by integrating Starter
rely, 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.