Spring Boot is so popular right now, there are so many technical articles and paid tutorials, and for those of you who don’t know what Spring Boot is, what is it? What’s the use? Today I will give you a detailed introduction.

Spring Boot background

To understand Spring Boot, you must first talk about the Spring framework!

In today’s flourishing Java backend framework, the Spring framework is undoubtedly the most popular and essential open source framework, and is firmly the leader of the Java backend framework.

Anyone who has used the Spring framework knows that Spring is popular because of two powerful things: IOC and AOP, IOC can help us manage the dependency of objects, greatly reduce the coupling of objects, and AOP’s aspect programming function can be more aspects of the use of dynamic proxy to achieve a variety of dynamic method functions (such as transactions, caching, logging, etc.).

To integrate with the Spring framework, you must use XML configuration files or annotated Java code configuration. Whether you use XML or code configuration, you need to know enough about the configuration of the relevant components to write a lot of lengthy configuration code.

And how many developers can master these configurations? Wouldn’t it be so easy if we just provided configuration parameters for the framework to automatically configure these components?

The Spring Boot framework was created to simplify the process of getting started.

What is Spring Boot?

Spring Boot is a sub-project of the Spring open source organization and a one-stop solution for Spring components. It mainly aims to simplify the difficulty of using the Spring framework and save heavy configuration.

Spring Boot provides “Starters” for various components. As long as developers can set the specific parameters for each component, Spring Boot will automatically configure them, allowing developers to quickly build Java projects that rely on Spring components.

Spring Boot can not only create traditional WAR package applications, but also create standalone applications that do not depend on any external container (such as tomcat) and can be launched using the java-jar command. Spring Boot also provides a command-line tool to execute Spring scripts.

Spring Boot’s official website:

The projects. Spring. IO/spring – the boot…

Spring Boot

Github.com/spring-proj…

Design goals for Spring Boot

If you’re not sure what Spring is for, take a look at what it was designed for!

  • Provide a faster, easier start experience for Spring application development;
  • Provides a set of common non-functional features commonly used in large projects, such as embedded servers, security, metrics, health checks, and external configurations;
  • Zero code configuration generation and zero XML configuration;

Why is Spring Boot so popular?

Why is Spring Boot so popular? Because it has the following characteristics.

1. Independent operation

Spring Boot is embedded with various Servlet containers, such as Tomcat, Jetty, and so on. Now there is no need to deploy into a war package in the container. Spring Boot can run independently as long as it is made into an executable JAR package, and all dependencies are in a JAR package.

2. Simplify Maven configuration

As shown in the figure above, you can now have the power of Spring Web by simply relying on the Spring-boot-starter-Web launcher package, which contains all web development dependencies, greatly reducing maven’s dependency configuration.

The full dependency tree can also be seen using the Maven command: MVN Dependency :tree:

[INFO] + - org. Springframework. The boot: spring - the boot - starter - web: jar: 2.0.1. RELEASE: the compile [INFO] | + - Org. Springframework. The boot: spring - the boot - starter: jar: 2.0.1. RELEASE: the compile (INFO) | | + - Org. Springframework. The boot: spring - the boot: jar: 2.0.1. RELEASE: the compile (INFO) | | + - Org. Springframework. The boot: spring - the boot - autoconfigure: jar: 2.0.1. RELEASE: the compile (INFO) | | + - Org. Springframework. The boot: spring - the boot - starter - logging: jar: 2.0.1. RELEASE: the compile (INFO) | | | + - Ch. Qos. Logback: logback - classic: jar: 1.2.3: compile [INFO] | | | | \ - ch. Qos. Logback: logback - core: jar: 1.2.3: compile/INFO | | | +- org.apache.logging.log4j:log4 j - to - slf4j jar: 2.10.0: compile [INFO] | | | | \ - org. Apache. Logging. Log4j:log4 j - API: jar: 2.10.0: compile [INFO] | | | \ - org. Slf4j: jul - to - slf4j: jar: 1.7.25: compile [INFO] | | + - Javax.mail. Annotation: javax.mail. The annotation - API: jar: 1.3.2: compile [INFO] | | \ - org. Yaml: snakeyaml: jar: 1.19: the runtime [INFO] | + - Org. Springframework. The boot: spring - the boot - starter - json: jar: 2.0.1. RELEASE: the compile (INFO) | | + - Com. Fasterxml. Jackson. Core: Jackson - databind: jar: 2.9.5: compile [INFO] | | | + - Com. Fasterxml. Jackson. Core: Jackson - annotations: jar: 2.9.0: compile [INFO] | | | \ - Com. Fasterxml. Jackson. Core: Jackson - core: jar: 2.9.5: compile [INFO] | | + - Com. Fasterxml. Jackson. Datatype: Jackson - datatype - jdk8: jar: 2.9.5: compile [INFO] | | + - Com. Fasterxml. Jackson. Datatype: Jackson - datatype - jsr310: jar: 2.9.5: compile [INFO] | | \ - Com. Fasterxml. Jackson. The module: Jackson - module - parameter - names: jar: 2.9.5: compile [INFO] | + - Org. Springframework. The boot: spring - the boot - starter - tomcat: jar: 2.0.1. RELEASE: the compile (INFO) | | + - Org, apache tomcat. Embed: tomcat embed - core: jar: 8.5.29: compile [INFO] | | + - Org, apache tomcat. Embed: tomcat embed - el: jar: 8.5.29: compile [INFO] | | \ - Org, apache tomcat. Embed: tomcat embed - websocket: jar: 8.5.29: compile [INFO] | + - Org. Hibernate. The validator: hibernate validator - : jar: 6.0.9. Final: compile [INFO] | | + - Javax.mail. Validation: validation - API: jar: 2.0.1. Final: compile [INFO] | | + - Org. Jboss. Logging: jboss - logging: jar: 3.3.2 rainfall distribution on 10-12. Final: compile [INFO] | | \ - com fasterxml: classmate: jar: 1.3.4: compile the INFO | + - org. Springframework: spring - web: jar: 5.0.5. RELEASE: the compile (INFO) | | \ - Org. Springframework: spring - beans: jar: 5.0.5. RELEASE: the compile | \ [INFO] - Org. Springframework: spring - webmvc: jar: 5.0.5. RELEASE: the compile [INFO] | + - Org. Springframework: spring aop: jar: 5.0.5. RELEASE: the compile [INFO] | + - Org. Springframework: spring - the context: jar: 5.0.5. RELEASE: the compile | \ [INFO] - Org. Springframework: spring - expression: jar: 5.0.5. RELEASE: the compileCopy the code

3. Automatic configuration

Spring Boot can automatically configure Spring beans according to the classes in the current classpath or the classes in the JAR package. For example, adding a Spring-boot-starter-Web initiator can have the Web function without other configuration. You can also customize the assembly by adding relevant configurations to the configuration file. This will be covered in a later class, so stay tuned.

4. No code generation and XML configuration

Spring Boot configuration is done without code generation and without XML configuration files, all with the help of conditional annotations, one of the core features of Spring 4+.

5. Application monitoring

Spring Boot provides a series of endpoints to monitor services and applications and perform health checks on Spring applications.

Disadvantages of Spring Boot

Having said so much about Spring Boot’s advantages and features, while it’s easy to get started, it’s not without its drawbacks. Any framework has its pros and cons, and Spring Boot is no exception, and I can probably summarize the following.

1. It is necessary to have a good understanding of the core technology principles of Spring Boot, otherwise it will be difficult once problems are encountered. Because everything is integrated, automatically configured. As such, you need to be familiar with the configuration information, and it is not easy to find problems.

2. It is difficult to smooth the migration from the original Spring project to the Spring Boot framework because some old XML configurations cannot be configured in Java and the need for additional XML files is not perfect. For example, if Tomcat was previously standalone and everything was configured online, you would have a lot of problems switching to built-in Tomcat.

Compared with the advantages, these disadvantages are not much. In short, Spring Boot is something that any of us Java developers should try to figure out.

In the end, the stack manager will share the latest technology tutorial of Spring Boot. Now he has written a pile of inventory, follow the wechat public account “Java Technology stack “, the public account will be pushed as soon as possible!