您的位置:首页 > 博客中心 > 编程语言 >

Spring Boot 学习(一) Condition

时间:2022-03-29 01:52

通过application类中的main方法里面的run方法

@SpringBootApplication
@ServletComponentScan(basePackages = "com.sp")      //可以自动将写的servlet扫描进去  配置扫描的包
@MapperScan("com.sp.mapper")
public class BootWeb01Application {
    public static void main(String[] args) {
        SpringApplication.run(BootWeb01Application.class, args);
    }

点进去run方法可以看见它是ConfigurableApplicationContext类的实例

@SpringBootApplication
@ServletComponentScan(basePackages = "com.sp")      //可以自动将写的servlet扫描进去  配置扫描的包
@MapperScan("com.sp.mapper")
public class BootWeb01Application {

    public static void main(String[] args) {
        //这样就可以启动springboot的应用,返回spring的IOC容器
        ConfigurableApplicationContext context = SpringApplication.run(BootWeb01Application.class, args);
    }
}

与此同时可以通过context.getBean("bean的名字") 来获取对应的bean组件

 

 

本类排行

今日推荐

热门手游