First knowledge of Spring Boot

Source: Internet
Author: User
Tags spring boot actuator

What is Spring boot?

Spring Boot is based on spring, in order to solve the spring framework with a wide range of configurations, complex deployment processes, and low development efficiency. If the spring goal is to simplify Java development, you can assume that the goal of the Spring Boot framework is to simplify the development of spring. Spring boot can create standalone programs with Tomcat, Jetty, and so on, and can launch applications directly without the need for external containers. At the same time, spring boot can automatically configure the spring application and integrate some of the framework's dependencies, such as developing a Web application that simply introduces starter to the Web, greatly simplifying package references. Since spring was created, spring boot is probably the most exciting thing in the spring world. It builds a new development model on top of spring, removing tedious content from the development of spring applications.

Spring boot provides spring boot Starter, automatic configuration, command line interface, actuator four key features that change the way the spring application is developed.

Spring Boot Starter: It consolidates common dependency groupings and merges them into a dependency so that they can be added to the project's Maven or Gradle build at once ;

automatic configuration : Spring Boot's auto-configuration feature leverages spring 4 's support for conditional configuration, and reasonably guesses the configuration of the bean automation required to apply them.

Command Line Interface (Commond-line interface,cli): The spring CLI has the advantage of the groovy programming language and, combined with automatic configuration, further simplifies the development of spring applications;

Actuator: It adds some management features to the spring boot app.

Spring Boot Starter (dependency transitivity)

Spring boot Satarter Aggregates the various dependencies required by the application into one dependency. The way it works makes use of Maven and Gradle's dependency delivery scheme , starter declares multiple dependencies in its own pom.xml file. When we add a starter dependency to a Maven or Gradle build, the dependency of starter will automatically be parsed. These dependencies may also have other dependencies. A starter may introduce dozens of dependencies in a transitive manner.

Automatic configuration

The auto-configuration feature reduces the number of spring configurations, using a convention that is better than the configuration, greatly reducing some of the configuration in spring. When implemented, it takes into account other factors in the application and infers the spring configuration you need.

Scenario 1: Use the Thymeleaf template as a view of spring MVC, at least three bean:thymeleafview-resolver, Springtemplateengine,templateresolver. But with spring boot autoconfiguration, all we need to do is add thymeleaf to the classpath of the project. If spring boot probe Thymeleaf is located in the classpath, it will infer that we need to use thyemeleaf to implement the view functionality of spring MVC and to automatically configure these beans.

The scene 2:spring boot starter also triggers automatic configuration. In the spring boot application, if we want to use spring MVC, all we need to do is put the Web starter as a dependency into the build. When you put Web starter as a dependency into the build, it automatically adds spring MVC dependencies (the dependency transitivity mentioned earlier). If spring Boot's web Autoconfiguration detects that spring MVC is located under the Classpath, it will automatically configure multiple beans that support spring MVC, including the view resolver, the resource processor, and the message converter. What we need to do next is write the controller that handles the request. If you have previously configured a spring MVC project from scratch, you will understand the efficiency that this brings.

Spring Boot CLI

The Spring boot CLI takes full advantage of the magic of Spring boot starter and autoconfiguration, and adds some groovy features that simplify the spring development process by running one or more groovy scripts and seeing how it works through the CLI. During application run, the CLI is able to automatically import the spring type and resolve dependencies.

There is a practice in which unit test code is written in groovy, resulting in an increase in efficiency.

Actuator

Spring Boot Actuator Provides a number of useful features for the spring boot project, including

    • Manage Endpoints

    • Reasonable exception handling and the default "/error" Mapping Endpoint

    • Get the app's "/info" endpoint

    • There is an audit event framework when spring security is enabled

These features are useful, but the most useful and interesting thing about actuator is managing endpoints, which opens a window that allows us to gain insight into the internal application health.

These are the main four features of spring boot, the Spring boot starter reduces the length of the dependent list, and the auto-configuration feature cuts down the number of spring configurations. The Spring Boot CLI brings a boost to development testing efficiency by combining with groovy.

Spring Boot Actuator provides a window into which we can monitor the health of the application. Embedded Tomcat, jetty and other containers, can start the application directly without the need for external containers these features also bring great convenience and efficiency to development, commissioning, and project deployment, and Spring boot has brought great changes to the development, testing, deployment, operations and other dimensions. Greatly simplifies these aspects of complexity, resulting in a significant increase in efficiency, but also for the back of the micro-service provides the basis.

First knowledge of Spring Boot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.