springboot面试题总结
1 Spring Boot的配置文件格式 application.properties或者是application.yml,它们的区别主要是书写格式不同。 1).properties: springboot.user.name = testname 2).yml: springboot: user: name: testname 另外,.properties格式文件的属性是无序的,.yml 格式文件的属性是有序的,但它不支持@PropertySource注解导入配置。 2 Spring Boot的核心注解 启动类上面的注解是@SpringBootApplication,它也是Spring Boot的核心注解,主要组合包含了以下3个注解: @SpringBootConfiguration:组合了 @Configuration 注解,实现配置文件的功能。 @EnableAutoConfiguration:打开自动配置的功能,也可以关闭某个自动配置的选项,如关闭数据源自动配置功能:@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })。 @ComponentScan:Spring组件扫描。 3 开启Spring Boot特性的方式 1)继承spring-boot-starter-parent项目 2