SpringBoot 常用注解
@SpringBootApplication 这个配置等同于:@Configuration ,@EnableAutoConfiguration 和 @ComponentScan 三个配置。 @EnableAutoConfiguration Spring Boot自动配置(auto-configuration),可以将@EnableAutoConfiguration或者@SpringBootApplication注解添加到一个@Configuration类上来选择自动配置。 如果发现应用了你不想要的特定自动配置类,可以使用@EnableAutoConfiguration注解的排除属性来禁用它们。 @Configuration 相当于传统的xml配置文件,如果有些第三方库需要用到xml文件,建议仍然通过@Configuration类作为项目的配置主类,可以使用@ImportResource注解加载xml配置文件。 @ComponentScan @ComponentScan 注解对应XML配置形式中的 <context:component-scan> 元素,表示启用组件扫描,Spring 会自动扫描所有通过注解配置的 bean,然后将其注册到 IOC 容器中。 可以通过 basePackages 等属性来指定 @ComponentScan 自动扫描的范围,如果不指定,默认从声明