Quick overview of how to create a Spring-boot project, a simple summary of how spring works, and a simple understanding of spring annotations.

Source: Internet
Author: User

As a developer, we create projects through development tools. Often we use (e.g. Eclipse, IntelliJ idea) to quickly build project structures) but sprig-boot projects we don't need to rely on development tools to

We can create projects with a convenient approach provided by spring:

Here is the address that the Sprig-boot project quickly created:

Address: http://start.spring.io/

After entering this address, we can see the relevant buttons; The graphical interface will know what it means to be a little bit more.

As shown above in the related settings. You can make the relevant settings. Finally, a ZIP package is generated. Then unzip into your own development tools, and then do the relevant development.

After our project is created we open the project and look at:

We can see a main class that is automatically created for us, and a comment such as @springbootapplication:

Let's read a few simple meanings:

@SpringBootApplication is the core annotation of spring boot, which is itself a combination of annotations that contains a set of features for the boot configuration, so let's look at the source code:

@SpringBootConfiguration @enableautoconfiguration@componentscan
These three parameters are important parameters:

@SpringBootConfiguration indicates that this is a configuration,
@EnableAutoConfiguration indicates that spring boot is automatically configured for the current project based on the jar package dependencies in the classpath.
For example, by adding the base dependency of Spring-boot-starter-web, Spring boot automatically adds the dependencies of Tomcat and spring MVC and configures them automatically.
@ComponentScan represents an automatic bean scan injection that everyone is familiar with.

@SpringBootApplication is equivalent to @springbootconfiguration, @EnableAutoConfiguration, @ComponentScan three roles

Let's talk about the start of Spring-boot:

Spring boot is implemented by an entry class called *application, which is actually a standard Java static method class, except that it uses an object Springapplication run method in the class to start the spring Boot project.

Since spring boot automatically scans the siblings of the @springbootapplication class and all the beans in the sub-package, the official recommendation is that the Ingress class be placed under the outermost package name.

Quick overview of how to create a Spring-boot project, a simple summary of how spring works, and a simple understanding of spring annotations.

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.