Using Spring Boot —— Using the @SpringBootApplication Annotation

注解@SpringBootApplication相当于下面三个注解:

  @EnableAutoConfiguration  自动配置

  @ComponentScan  扫描指定包下的所有@Component

  @Configuration  允许注册@Bean / 导入Configuration类(@Import) 

 

 

package com.example.myapplication;

import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@EnableAutoConfiguration
@Import({ MyConfig.class, MyAnotherConfig.class })
//@SpringBootApplication
public class Application {

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

}

 

posted on 2019-09-17 10:24  李笑白  阅读(98)  评论(0编辑  收藏  举报

导航