Getting explain SpringBoot--

First, what is SprigBoot, what's the use?

It is a micro-services: a project can be (micro service) constituted by a plurality of small service
role: Boot spring can quickly develop micro service module
    . A simplified j2ee development
    . B integration of the entire spring stack technology (integrated spring SpringMVC)    
    . C throughout j2ee integration technology (integrated mybatis redis)

Two, SpringBoot directory structure and the role:

Here I created a maven type of springboot

Directory Structure

    Resources:
    static: static resources (js css Image Audio Video)
    Templates: template file (template engine freemarker, thymeleaf; default does not support JSP)
    application.properties: Profile

Third, the service class notes role:

package org.skh.spring.HelloSpringBoot;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HelloSpringBootApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloSpringBootApplication.class, args);
	}
}

Once up and running it as a javaapplication, equivalent turned on the server, it can access your requestMapping and other static resources by the browser localhost + port. This class inside annotation @SpringBootApplication can be described as critical.

@SpringBootApplication also contains a number of comments, I say something which is particularly important for two reasons:

i:@SpringBootConfiguration:

He also included a note called the @Configuration, its role is to have the @Configuration annotated classes to join the Spring container, Spring is not here to explain what the container. Also declares that this class is a class configuration.

ii:@EnableAutoConfiguration:

1. We know that when we need to use SpringMvc annotated package is scanned, such as Controller, but we need to be hard-coded configuration, this role is to comment @SpringBootApplication bags annotations and where sub-scanning package is added. It belongs to our hand-code configuration.

2. reliance on third parties (jar) to configure:

With this comment after, spring boot at startup, will find the corresponding three-way dependence according to META-INF / spring.factories, and these depend on the introduction of the project

Summary:
    When writing the project, the general will write their own code and configure the three parties rely on. But spring boot can be configured to automatically:
      A: write your own code, spring boot configuration by automatically help us @SPringBootApplication in @SpringBootConfiguration;
      b tripartite reliance by spring-boot-autoconfigure-2.0.3.RELEASE.jar in.
         The META -INF / spring.factories declared, then turn use by @SpringBootApplication in @EnableAutoConfiguration.
    tips: spring-boot-autoconfigure- 2.0.3.RELEASE.jar package contains system-dependent J2EE integration required.

 

Guess you like

Origin blog.csdn.net/z_xindong/article/details/93480080