Review what annotations are

  • What are Java annotations, and what do they do?

Review the Spring annotations

  • Spring annotation development (Java-based container configuration)

Automatically.

  • XML auto-assembly or annotation auto-assembly of Spring beans

How does Spring Boot assign values to objects (assemblies)

  • SpringBoot Introduction to the use of YAML
  • annotations@configurationProperties (prefix = "corresponding prefix in YAML file ")The meaning of

Spring Boot assembly shallow understanding

First we break down which classes it can assemble

  • Found in dependenciesOrg. Springframework. The boot: spring - the boot - autoconfigure: 2.4.4To open the mate-info filespring.factoriesFile, the class inside is the class that can be assembled.

  • Click on a class and call itHttpEncodingAutoConfigurationThe class!

  • Observe the annotation

  • Click on classes that can be configuredServerProperties

  • Classes that do not assemble

To have a class you need to import a dependency or customize one

summary

SpringBoot loads a large number of auto-configuration classes (in the spring.factories file under mate-info).

conditionconditionconditionconditionconditionconditionconditionconditionconditionalxxx

In application.yaml, add the debug=true attribute to see which classes are assembled and which are not

3. We look to see if the functionality we need is in the automatic configuration class written by default in SpringBoot to decide whether to write it ourselves

Let’s take a look at the components configured in the automatic Configuration class xxxxAutoConfigurartion. (As long as the component we want to use (@Configuration) exists in it, we don’t need to configure it manually.)

When you add a component to the auto-configuration class in the container, you get some properties from the xxxxProperties class. We only need to specify the values of these attributes in the configuration file (application.yaml);

XxxxAutoConfigurartion: automatic configuration class; Add components to the container

XxxxProperties: Properties that can be written in the configuration file (application.yaml);

6. If you know what classes you need to write or import, and what properties you can write (configure) in application.yaml, you don’t need to remember too much configuration in general