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.