Spring Boot Learning Summary (ii)--some basic points about @springbootapplication

Source: Internet
Author: User

1. @SpringBootApplication

It is a composite annotation, in fact, for springboot applications, the most important thing is that there are only three

@Target (Elementtype.type) @Retention (retentionpolicy.runtime) @Documented @inherited
//Three of the most important @Configuration @enableautoconfiguration@componentscan
public @interface springbootapplication{...}

It's too cumbersome to write three annotation at a time

@Configuration @enableautoconfiguration@componentscan  Public class demoapplication {    publicstaticvoid  main (string[] args) {        Springapplication.run (springboot01application. class , args);}    }

Can simplify, write a @springbootapplication one-stop compound

@SpringBootApplication  Public class demoapplication {    publicstaticvoid  main (string[] args) {        Springapplication.run (springboot01application. class , args);}    }

2. @ComponentScan

Function: Automatically scans and loads eligible component or bean definitions, then loads into containers

3, @EnableAutoConfiguration, is also a composite annotation

@Target (Elementtype.type) @Retention (rententionpolicy.runtime) @ Documented@inherited@autoconfigurationpackage@import (enableautoconfigurationimportselector.class)  public @interface enableautoconfiguration{...}

The most critical is @import, which loads all eligible @configuration configurations into the IOC container created and used by the current springboot.

With the support of the original tool class Springfactoriesloader of the spring framework, @EnableAutoConfiguration can achieve "intelligent" automation configuration.

--End--to be continued ~

Spring Boot Learning Summary (ii)--some basic points about @springbootapplication

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.