1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@SpringBootApplication
public class Demo15Application {
public static void main(String[] args) {
ApplicationContext run = SpringApplication.run(Demo15Application.class, args);
Teacher bean = run.getBean(Teacher.class);
System.out.println(bean);
}
//在运行时执行
@Bean
CommandLineRunner cmd(CompanyMapper companyMapper){
return args -> {
List<Company> companies = companyMapper.selectList(null);
for (Company company:companies){
System.out.println(company);
}
};
}
}