SpringBoot core functions
spring-boot-starter: Spring Boot’s core starter, including auto-configuration, logging, and YAML
spring-boot-starter-aop: Supports AOP aspect-oriented programming features, including spring-aop and AspecJ
spring-boot-starter-cache: Support Spring’s Cache abstraction
spring-boot-starter-artermis: API that supports JMS (Java Message Service) through Apache Artemis
spring-boot-starter-data-jpa: Support JPA
spring-boot-starter-data-solr: Supports the Apache Solr search platform, including spring-data-solr
spring-boot-starter-freemarker: Support FreeMarker template engine
spring-boot-starter-jdbc: Support JDBC database
spring-boot-starter-Redis: Support Redis key-value storage database, including spring-redis
spring-boot-starter-security: support spring-security
spring-boot-starter-thymeleaf: Support for Thymeleaf template engine, including integration with Spring
spring-boot-starter-web: Support full stack web development, including tomcat and Spring-WebMVC
spring-boot-starter-log4j: Support Log4J logging framework
spring-boot-starter-logging: Introduce Spring Boot’s default logging framework Logback
Run the Spring project independently
Spring boot can run independently in the form of a jar package. To run a Spring Boot project, you only need to run it through java -jar xx.jar.
- The embedded servlet container
Spring Boot can choose to embed Tomcat, jetty or Undertow, so that we do not need to deploy the project in the form of war package.
- Provide starter to simplify Maven configuration
Spring provides a series of start poms to simplify Maven dependency loading. For example, when you use spring-boot-starter-web, the dependency package shown in Figure 5-1 will be automatically added.
- Automatic assembly Spring
SpringBoot will automatically configure beans for the classes in the jar package according to the jar package, class, and class in the jar package, which will greatly reduce the configuration we want to use. Of course, SpringBoot only considers most development scenarios, not all scenarios. If we need to configure beans in actual development, and SpringBoot provides support, you can customize automatic configuration.
- Quasi-production application monitoring
SpringBoot provides monitoring of runtime projects based on http ssh telnet.
- No-code production and xml configuration
SpringBoot is not implemented by means of code generation, but by conditional annotation, which is a new feature provided by Spring4.x.
Advantages and disadvantages of SpringBoot
Create a standalone Spring application
Embedded Tomcat, no need to deploy WAR file
Simplified Maven configuration
Automatically configure Spring
Provide production-ready features such as metrics, health checks, and external configuration
Absolutely no code generation and no configuration requirements for XML
1. If you don’t agree with the spring framework, maybe this is the disadvantage.
2. SpringBoot features
3. Create independent Spring projects
4. Built-in Tomcat and Jetty containers
5. Provide a starter POMs to simplify Maven configuration
6. Provide a series of non-functional features common in large projects, such as security, metrics, health Detection, external configuration, etc.
7. No code generation and xml configuration files at all
SpringBoot CLI is a console command tool provided by SpringBoot.
SpringBoot maven build project
spring-boot-starter-parent: It is a special Start, which is used to provide related Maven dependencies. After using it, the version tag can be omitted for commonly used package dependencies.
Several common annotations of SpringBoot
(1) @RestController and @Controller specify a class as an annotation for the controller, and explain the difference
(2) @RequestMapping method-level mapping annotation, this one who has used Spring MVC is believed to be familiar
(3) @ EnableAutoConfiguration and @SpringBootApplication are class-level annotations. According to the jar that maven depends on, the correct spring configuration is automatically guessed. As long as the dependency of spring-boot-starter-web is introduced, Spring MVC and tomcat containers will be automatically configured by default
(4) @Configuration class-level annotation. Generally, this annotation is used to identify the class where the main method is located and complete the initialization of the metadata bean.
(5) @ComponentScan class-level annotation, which automatically scans and loads all Spring components including bean injection, generally used on the class where the main method is located
(6) @ImportResource class-level annotation, when we must use an xml configuration, use @ImportResource and @Configuration to identify the class of this file resource.
(7) @Autowired annotation, generally combined with @ComponentScan annotation, to automatically inject a Service or Dao-level Bean
(8) @Component class-level annotation, used to identify a component, for example, if I customize a filter, this annotation is required After the identification, Spring Boot will recognize it correctly.
How does springboot manage transactions? Just write the @transactional annotation directly, the method is the method transaction, and the class is the class transaction