What is a springboot
Spring Boot is a sub-project of Spring open source organization. It is a one-stop solution for Spring components. It mainly simplifies the difficulty of using Spring, saves heavy configuration, and provides various initiators for developers to get started quickly. Spring Boot is not an enhancement to Spring functionality, but rather provides a quick way to use Spring.
# springboot function
- Automatic configuration: SpringBoot’s automatic configuration is a run-time (or, more accurately, application startup) process where SpringBoot automatically completes which Spring configuration should and should not be used.
- Starting dependencies: Dependency passing to other libraries is defined without version conflicts
- Ancillary features: Provides non-functional features common in large projects, such as embedded servers, security, metrics, health checks, external configuration, etc.
What are the core annotations for SpringBoot? Which notes are it mainly composed of?
- The @springBootApplication annotation on the startup class is the core annotation and contains the following three annotations:
- @springBootConfiguration: contains @Configuration to implement the function of Configuration files.
- @enableAutoConfiguration: enables the automatic configuration function.
- @ComponentScan: Spring component scanning
Does SpringBoot need a separate container to run?
Tomcat/Jetty containers are built in. Tomcat is the default
What are the ways to run SpringBoot?
- Package to run with commands or in containers
- Execute the main method directly
- Run with the Maven plugin
What is the principle of Spring Boot automatic configuration?
- The @EnableAutoConfiguration annotation is at the heart of automatic configuration. Annotations for internal use @ Import (AutoConfigurationImportSelector. Class) (class which loading configuration file used to class) annotations to load the configuration class, not all of the beans are loaded, Use @condition in a configuration class or bean to load a bean that meets the Condition.
- @enableAutoConfiguration Imports the autoconfiguration classes defined in meta-INF/Spring. factories and filters the valid ones. Each automatic configuration class is combined with the corresponding xxxproperties.java to read configuration files for automatic configuration
SpringBoot automatic configuration -Condition
- Condition is a conditional configuration interface introduced after Spring4.0. By implementing Condition interface, the corresponding Bean can be loaded conditionally
- @Conditional is used with the implementation of Condition (ClassCondition)
- Common condition notes provided by SpringBoot:
- ConditionalOnProperty: Initialize the Bean based on whether there are properties and values in the configuration file
- ConditionalOnClass: initialize the Bean by deciding whether the corresponding bytecode file exists in the environment
- ConditionalOnMissingBean: Initialize the Bean based on the ConditionalOnMissingBean condition
Is Spring Boot compatible with older Spring projects, and how?
- Yes, use the @importResource annotation to import the old Spring project configuration file. Used on startup classes.
SpringBoot configuration – profile
- A profile is used to configure dynamic switchover in different environments
- Profile Configuration Mode
Multi-profile approach: Provide multiple profiles, each representing an environment. Properties/yML development environment application-test.properties/ yML test environment application-pro.properties/ YML production environment
- Profile Activation Mode
Configuration file: spring.profiles. Active =dev
Springboot monitor physical
- Spring Boot Actuator is one of the important functions in Spring boot framework. Spring Boot has its own monitoring function, which helps to monitor the internal running status of programs, such as monitoring status, Bean loading, configuration properties, log information, etc.
The last
At the end of the article the author sorted out a lot of information for you! Including Java core knowledge + a full set of architect learning materials and video + first-line factory interview treasure dictionary + resume template interview ali Meituannetease Tencent Xiaomi IQiyi Quick hand bilibili bilibili interview questions +Spring source code collection +Java architecture actual combat e-books and so on! Welcome to pay attention to the public number: the future has light, receive!