超详细的SpringBoot面试题,Java面试题

我把所有Java相关的面试题和答案都整理成了PDF,并且带书签目录,阅读起来非常方便

面试题及答案PDF下载https://www.hicxy.com/?p=2645

面试题及答案PDF下载https://www.hicxy.com/?p=2645

面试题及答案PDF下载https://www.hicxy.com/?p=2645

1. Spring Boot 的核心注解是哪个?它主要由哪几个注解组成的?

启动类上面的注解是@SpringBootApplication,它也是 Spring Boot 的核心注解,主要组合包含了以下 3 个注解:

@SpringBootConfiguration: 组合了 @Configuration 注解,实现配置文件的功能。

@EnableAutoConfiguration: 打开自动配置的功能,也可以关闭某个自动配置的选项,如关闭数据源自动配置功能:@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })。

@ComponentScan: Spring组件扫描。

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="java" cid="n12" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: "Roboto Mono", "Source Sans Pro", "Microsoft YaHei", 微软雅黑 !important; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; width: inherit; -webkit-font-smoothing: initial; line-height: 1.55rem; word-wrap: normal; color: var(--mid-10); margin: 1.8rem 0px 2rem !important; background-position: inherit inherit; background-repeat: inherit inherit;">@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = {
@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {</pre>

2. 什么是YAML?

3. 运行 Spring Boot 有哪几种方式?

4. springboot自动配置的原理

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="java" cid="n33" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: "Roboto Mono", "Source Sans Pro", "Microsoft YaHei", 微软雅黑 !important; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; width: inherit; -webkit-font-smoothing: initial; line-height: 1.55rem; word-wrap: normal; color: var(--mid-10); margin: 1.8rem 0px 2rem !important; background-position: inherit inherit; background-repeat: inherit inherit;">@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration

</pre>

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="java" cid="n36" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: "Roboto Mono", "Source Sans Pro", "Microsoft YaHei", 微软雅黑 !important; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; width: inherit; -webkit-font-smoothing: initial; line-height: 1.55rem; word-wrap: normal; color: var(--mid-10); margin: 1.8rem 0px 2rem !important; background-position: inherit inherit; background-repeat: inherit inherit;">@Override
public String[] selectImports(AnnotationMetadata annotationMetadata) {
if (!isEnabled(annotationMetadata)) {
return NO_IMPORTS;
}
// 获取配置的元数据
AutoConfigurationMetadata autoConfigurationMetadata = AutoConfigurationMetadataLoader
.loadMetadata(this.beanClassLoader);
// 这个方法包含了加载的主要逻辑,它能找到所有自动注入的类
AutoConfigurationEntry autoConfigurationEntry = getAutoConfigurationEntry(
autoConfigurationMetadata, annotationMetadata);
return StringUtils.toStringArray(autoConfigurationEntry.getConfigurations());
}

</pre>

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="java" cid="n39" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: "Roboto Mono", "Source Sans Pro", "Microsoft YaHei", 微软雅黑 !important; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; width: inherit; -webkit-font-smoothing: initial; line-height: 1.55rem; word-wrap: normal; color: var(--mid-10); margin: 1.8rem 0px 2rem !important; background-position: inherit inherit; background-repeat: inherit inherit;">protected AutoConfigurationEntry getAutoConfigurationEntry(
AutoConfigurationMetadata autoConfigurationMetadata,
AnnotationMetadata annotationMetadata) {
// ....
// 获取候选配置类
List<String> configurations = getCandidateConfigurations(annotationMetadata, attributes);
// ... 过滤、去重、排除一些配置类
return new AutoConfigurationEntry(configurations, exclusions);
}

</pre>

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="java" cid="n45" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: "Roboto Mono", "Source Sans Pro", "Microsoft YaHei", 微软雅黑 !important; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; width: inherit; -webkit-font-smoothing: initial; line-height: 1.55rem; word-wrap: normal; color: var(--mid-10); margin: 1.8rem 0px 2rem !important; background-position: inherit inherit; background-repeat: inherit inherit;">...

Auto Configure

org.springframework.boot.autoconfigure.EnableAutoConfiguration=
org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,
org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,
...

</pre>

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="java" cid="n48" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: "Roboto Mono", "Source Sans Pro", "Microsoft YaHei", 微软雅黑 !important; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; width: inherit; -webkit-font-smoothing: initial; line-height: 1.55rem; word-wrap: normal; color: var(--mid-10); margin: 1.8rem 0px 2rem !important; background-position: inherit inherit; background-repeat: inherit inherit;">org.springframework.boot.autoconfigure.EnableAutoConfiguration=
org.yuan.interview.springboot.XXXAutoConfiguration</pre>

5. spring-boot-starter-parent 有什么用 ?

6. SpringBoot自动配置原理是什么?

7. Spring Boot 中如何解决跨域问题 ?

8. 如何使用 Spring Boot 实现分页和排序?

9. Spring Boot 中的 starter 到底是什么

10. Spring Boot 有哪几种读取配置的方式?

11. 什么是嵌入式服务器?我们为什么要使用嵌入式服务器呢?

12. Spring Boot 中如何实现定时任务 ?

13. Spring Boot扫描流程?

14. Spring Boot中的监视器是什么?

15. 什么是 CSRF 攻击?

16. 创建一个 Spring Boot Project 的最简单的方法是什么?

17. 怎么理解 Spring Boot 中 “约定优于配置“

18. SpringBoot的原理

19. Spring Boot 还提供了其它的哪些 Starter Project Options?

20. Springboot 有哪些优点?

21. Spring Boot 配置加载顺序详解

22. 什么是 Spring Data?

23. Spring Boot、Spring MVC 和 Spring 有什么区别?

24. spring-boot-starter-parent 有什么用

25. Spring Initializr 是创建 Spring Boot Projects 的唯一方法吗?

26. 你如何理解 Spring Boot 中的 Starters?

27. SpringBoot常用的starter有哪些?

28. SpringBoot 实现热部署有哪几种方式?

29. Spring Boot 打成的 jar 和普通的 jar 有什么区别

30. 什么是 Spring Profiles?

31. Springboot集成mybatis的过程

32. 如何在自定义端口上运行 Spring Boot应用程序?

33. Spring Boot 如何定义多套不同环境配置?

34. 如何禁用一个特定自动配置类?

35. 比较一下 Spring Security 和 Shiro 各自的优缺点 ?

36. 什么是 Spring Batch?

37. Spring Boot 支持哪些日志框架?推荐和默认的日志框架是哪个

38. Spring Boot 的核心配置文件有哪几个?它们的区别是什么?

39. 如何集成 Spring Boot 和 ActiveMQ?

40. SpringBoot 需要独立的容器运行吗?

41. 什么是springboot ?

42. 微服务中如何实现 session 共享

43. Spring Boot 自动配置原理是什么?

44. 我们如何监视所有 Spring Boot 微服务?

45. 当 Spring Boot 应用程序作为 Java 应用程序运行时,后台会发生什么?

46. Spring Boot 是否可以使用 XML 配置 ?

47. YAML 配置的优势在哪里 ?

48. Spring Boot、Spring MVC 和 Spring 有什么区别?

49. 什么是 Swagger?你用 Spring Boot 实现了它吗?

50. SpringBoot启动时都做了什么?

51. Spring Boot 的目录结构是怎样的?

52. 什么是 Spring Boot Stater ?

53. RequestMapping 和 GetMapping 的不同之处在哪里?

54. Spring Boot 打成的 jar 和普通的 jar 有什么区别 ?

55. 如何重新加载Spring Boot上的更改,而无需重新启动服务器?

56. Spring Boot初始化环境变量流程?

57. 为什么我们需要 spring-boot-maven-plugin?

58. 什么是 JavaConfig?

59. spring boot 核心配置文件是什么?bootstrap.properties 和 application.properties 有何区别 ?

60. Spring Boot 的核心注解是哪个?它主要由哪几个注解组成的?

61. 为什么我们不建议在实际的应用程序中使用 Spring Data Rest?

62. 什么是JavaConfig?

63. 什么是 Spring Data REST?

64. spring boot的starter的执行原理

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容