SpringBoot core functions

Advantages and disadvantages SpringBoot

SpringBoot features

SpringBoot CLI

SpringBoot Maven build project

SpringBoot several commonly used annotations

SpringBoot core functions

1. Run Spring projects independently

Spring Boot can be independently run as a JAR package. To run a Spring Boot project, you only need to run the java-jar xx.jar.

2. Built-in servlet containers

Spring Boot can choose to embed Tomcat, Jetty, or Undertow so that we do not need to deploy projects as war packages.

3. Provide starter to simplify Maven configuration

Spring provides a series of Start PoMs to simplify dependency loading for Maven. For example, when you use spring-boot-starter-Web, the dependency packages shown in Figure 5-1 are automatically added.

4. Automatic Spring assembly

SpringBoot will automatically configure beans based on the jar packages, classes, and classes in the JAR packages in the classpath, greatly reducing the configuration we need to use. Of course, SpringBoot only considers most development scenarios, not all of them. If we need to configure beans during actual development and SpringBoot does not support this, we can customize the automatic configuration.

5. Application monitoring of quasi-production

SpringBoot provides HTTP-based SSH Telnet to monitor runtime projects.

No code production and XML configuration

SpringBoot is implemented not through code generation, but through conditional annotations, a new feature provided by Spring4.x.

Advantages and disadvantages SpringBoot

Advantages:

Build projects quickly.

Configuration-free integration with mainstream development frameworks.

Projects can run independently without external dependencies on the Servlet container. – Provides application monitoring at run time.

Greatly improve the efficiency of development and deployment.

Natural integration with cloud computing.

Disadvantages:

If you don’t agree with the Spring framework, maybe that’s a drawback.

SpringBoot features

Create a separate Spring project

Built-in Tomcat and Jetty containers

Provide a starter POMs to simplify Maven configuration

Provides a range of non-functional features common in large projects, such as security, metrics, health checks, external configuration, and more

No code generation or XML configuration files at all

SpringBoot CLI

SpringBoot CLI is a console command tool provided by SpringBoot.

SpringBoot Maven build project

Spring-boot-starter -parent: is a special Start used to provide Maven dependencies so that the version tag is omitted from common package dependencies.

SpringBoot several commonly used annotations

(1) @RestController and @Controller specify a class to annotate the Controller and explain the difference

(2) @requestMapping method level mapping annotation, which is familiar to those who used Spring MVC

(3) @enableAutoConfiguration and @SpringBootApplication are class-level annotations that automatically guess the correct spring configuration based on the JAR maven relies on. Once the spring-boot-starter-Web dependency is introduced, spring MVC and Tomcat containers are automatically configured by default

(4) @Configuration class level annotation. This annotation is used to identify the class of the main method and complete the initialization of the metadata bean.

(5) @ComponentScan class-level annotations that automatically scan and load all Spring components including Bean injection, typically used on classes where the main method is located

(6) @importResource class level annotations. When we must use an XML Configuration, use @importResource and @Configuration to identify the class of the file resource.

(7) The @AutoWired annotation, typically combined with the @ComponentScan annotation, automatically injects a Service or DAO-level Bean

(8) @component class-level annotation used to identify a Component. For example, if I set a filter, Spring Boot will need this annotation to identify it correctly.

How does SpringBoot manage transactions? Simply annotate @Transactional. A method is a method transaction and a class transaction.