SpringBoot 工程提供引导类用来启动程序,SpringBoot 工程启动后创建并初始化 Spring 容器
package com.itheima;标签:引导,springboot,ctx,springframework,springboot2,import,org From: https://www.cnblogs.com/gagaya2/p/17818380.html
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication //引导类,整个程序的入口,加载Bean
public class Springboot01Application {
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(Springboot01Application.class, args);//启动了一个Spring容器
Object bean = ctx.getBean("springboot01Controller");
System.out.println(bean);
}
}