@SpringBootApplication
is a convenience annotation that adds all of the following:
-
@Configuration
tags the class as a source of bean definitions for theapplication context. -
@EnableAutoConfiguration
tells Spring Boot to start adding beans based on classpath settings,other beans,and various property settings. -
Normally you would add
@EnableWebMvc
for a Spring MVC app, but Spring Boot adds it automatically when it sees spring-webmvc on the classpath. This flags the application as a web application and activates key behaviors such as setting up aDispatcherServlet
. (DispatcherServlet是什么可看这里 http://blog.csdn.net/zhouhuakang/article/details/50643034) -
@ComponentScan
tells Spring to look for other components, configurations, and services in the thehello
package, allowing it to find theHelloController
.