Spring Boot Reference Tutorial (ii) Springboot features

Source: Internet
Author: User

2. Spring boot Feature1. Starter Pom (start dependent)

Spring provides a series of Starterpom to simplify the dependency loading of MAVEN, referring to the official documentation 13.5 starters section.

What is Starterpom, the above article HelloWorld works as an example:

There are only three dependencies in a project's POM:

Where: Spring-boot-starter-web is required for the spring Web project, and when this dependency is used, the following dependencies are automatically added:

By relying on the tree, it can be seen that simply joining a Web starter pom automatically introduces the dependencies required in general Spring Web Engineering. Simple and convenient. Spring offers a variety of starter pom options.

Simply put,starter Pom is a set of dependent collections that combine to implement a feature. The benefits are self-evident!

2. Run standalone, inline servlet container

A big feature of Springboot is the ability to run independently, both directly and Java-jar, without the need to rely on the servlet container. Because it provides an inline servlet container.

1 of the three dependencies have one for Spring-boot-starter-tomcat this dependency for the project to provide inline servlet container Tomcat, in addition to the use of Jetty, Undertow as an inline container.

The Hello World Project selected in the Create option above is the War, so Spring-boot-starter-tomcat relies on the scope property of provide. Developer local boot is still the inline container used.

The test is started in jar mode:

1. Modify the package mode to jar and remove the Spring-boot-starter-tomcat scope property.

2. Packaging (change the engineering environment to JDK)

3. Start the jar package

Startup success

4. Test access

Test success!

3. Automatic Assembly

as can be seen from the Hello world, there is no manual configuration to initialize related beans such as: Jacksonobjectmapper,Dispatcherservlet, Beannameviewresolver,resourcehandlermapping and so on.

All the beans that are needed in the project for general Web applications are initialized by Spring boot.

View (see detailed descriptions of the methods later in this section) for all initialized beans:

Note:Spring boot automatically configures the Bean based on conditions such as jar packages, classes, and configuration files in the project classpath, such as: If the classpath has MyBatis and Oracle driver packages, Springboot automatically configures beans such as MyBatis's data source factory . Spring Boot's automatic assembly is implemented primarily through conditional configuration and annotations, which is the magic of Springboot.

Simply put, what you need to add dependencies, as long as your dependent jar packages meet the criteria,Springboot will automatically configure the relevant Bean for you to initialize .

If you have not yet understood what automatic assembly is, refer to the documentation and you will have a deep experience as you learn more about Spring boot!

4. Provide application internal monitoring (actuator)

In Spring Engineering, we are unable to monitor the internal operation of the application, such as the life cycle of the bean, the health of the application, etc.

To solve this problem,Spring boot provides the actuator actuator to monitor the application internally.

Details will be given in the next section.

< instance code >

Github:https://github.com/chunyuding/springboot-demo

Https://github.com/chunyuding/SpringBoot-Demo.git

Code Cloud: Https://gitee.com/dingchunyu/SpringBoot-Demo

Https://gitee.com/dingchunyu/SpringBoot-Demo.git

< recommended books >

Baidu Cloud: Http://pan.baidu.com/s/1qYA0Nxi

Spring Boot Reference Tutorial (ii) Springboot features

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.