1. java
1.1 基础知识
- 基础语法
- 基础数据结构及底层原理
- 并发包及底层原理
- 异常
- stream
- lamda表达式
- 面向对象
1.2 高级编程
- 线程池
- 锁
- 信号
1.3 JVM
- jvm内存结构
- GC算法
- jvm优化
1.4 java工具
- jmap
- jstack
- athas
2. mysql
2.1 mysql基础知识
- 字段类型及适用规则
- 基础sql写法
- 索引的原理
- 索引的失效条件
- 参数调优
- 锁的类型
- explain结果
2.2 数据库事务
- 事务的概念
- ACID:原子性、一致性、持久性、隔离性
- 事务传播类型
- REQUIRED
- REQUIRES_NEW
- NESTED
- SUPPORTS
- NOT_SUPPORTED
- NEVER
- MANDATORY
- 隔离级别
- READ_UNCOMMITED
- READ_COMMITTED
- REPEATABLE_READ
- SERIALIZABLE
- 常见并发问题
- 脏读
- 幻读
- 不可重复读
3. Redis
- 数据结构
- 常见的操作
- 底层原理(为何快)
- 集群搭建(怎么搭,哨兵模式)
4. 消息队列
4.1 kafka
- 基本部件
- 为何性能高
- 特性
4.2 nats
- 基本操作
- 底层原理
4.3 其他消息队列特性
4.4 消息队列的好处
5.spring
5.1 spring的核心特性
- 控制反转
- 依赖注入
- AOP
5.2 核心模块
- Core Container
- Context
- Web
- AOP
- MVC
- Data Access/Untegration
5.3 常用注解
- Component
- Service
- Controller
- Repository
- Autowired
- Configuration
- Bean
- RequestMapping/GetMapping/PostMapping
- RequestParam
- PathVariable
- ResponseBody
- RequestBody
- Transactional
- Order
5.4 SpringMvc核心组件
-
DispatcherServlet
-
HandlerMapping
-
HandlerAdpter
-
Handler
-
ViewResolver
5.5 常见面试问题
- Autowired(Spring)和Resource(JDK)的区别
- bean的生命周期
- component和Bean的区别
- Bean线程安全吗
- 循环依赖(@Lazy)
- Bean的初始化过程
- 统一异常处理怎么做(@ControllerAdvice
+@ExceptionHanlder) - 用到的设计模式
- 单例模式:Bean
- 工厂模式:BeanFactory
- 代理模式:AOP
- 模板方法:RestTemplate/JpaTemplate
- 观察者模式:ApplicationListener
6.Springboot
6.1 主要特点
- 约定大于配置
- 自动配置(EnableAutoConfiguration 自动扫描所有starter的META-INF/spring.factories 获取自动配置类的路径)
- 独立运行
- 内嵌服务器
6.2 核心注解
- SpringBootApplication
- SpringBootConfiguration
- EnableAutoConfiguration
- ComponentScan
6.3 配置文件的加载顺序
- bootstrap(不能覆盖)
- src/main/resources
目录下的application.properties或application.yml - application-{profile}.properties或application-{profile}.yml
- spring.config.location命令行参数,Spring Boot会按照指定的路径加载配置文件
- 系统环境变量
- 命令行参数
6.4 starters
- spring-boot-starter-web:用于构建 Web 应用程序的 Starter,包括 Spring MVC 和 Tomcat 服务器。
- spring-boot-starter-data-jpa:用于与关系型数据库进行交互的 Starter,用于简化数据库访问层的开发。
- spring-boot-starter-data-redis:用于与 Redis 数据库进行交互的 Starter。
- spring-boot-starter-actuator:用于监控和管理 Spring Boot 应用的 Starter。
- spring-boot-starter-security
- spring-boot-starter-test
- mybatis-spring-boot-starter
6.5 Spring Boot Actuator
/health:检查应用健康状态。/metrics:获取JVM内存、HTTP请求统计等指标。/env:查看环境变量和配置属性。/loggers:动态修改日志级别。
6.6 Spring Security
核心组件
- SecurityFilterChain:定义安全规则(如拦截路径、权限要求)。
- AuthenticationManager:处理认证流程,验证用户身份。
- AccessDecisionManager:决定用户是否有权访问资源。
- UserDetailsService:加载用户信息(如角色、权限)。
6.7 过滤器和拦截器的区别
- 技术栈所属不同:过滤器属于JavaWeb技术,依赖Servlet容器;而拦截器是属于Spring的技术
- 实现原理不同:拦截器是基于Java的反射机制,而过滤器是基于函数回调
- 拦截范围不同:过滤器可以拦截所有请求,而拦截器主要是针对发往controller请求
- 拦截位置不同:过滤器在前端控制器前拦截行,而拦截器在前端控制器后拦截
6.5 问答
- 跨域怎么解决:实现WebMvcConfigurer的addCorsMappings方法
- 定时任务:@Scheduled或Quartz
- session共享:redis
- 多环境:spring.profiles.active以及@Profile
- 配置文件覆盖的优先级:@Primary
- 排除自动配置:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
- 事务传播行为:@Transactional(propagation = Propagation.REQUIRED
- 隔离级别:@Transactional(isolation = Isolation.READ_COMMITTED
- 自定义HTTP消息转换器:HttpMessageConverters MappingJackson2HttpMessageConverter
- 文件上传:MultipartFile
- 文件下载:设置响应头
Content-Disposition - 拦截器实现:
- 实现Interceptor
- WebMvcConfigurer.addInterceptors
- 全局异常
- @ControllerAdvice
- @ExceptionHandler
- 测试:@SpringBootTest
- 异步任务:@EnableAsync
- 定时任务:@EnableScheduling @Scheduled(cron = "0 0 * * *")
- 可执行jar:spring-boot-maven-plugin
- 集中式日志:ELK(Elasticsearch + Logstash + Kibana)或EFK(Elasticsearch + Fluentd + Kibana)
- 优雅停机:
- server.shutdown=graceful
- spring.lifecycle.timeout-per-shutdown-phase=30s
- 发送
SIGTERM信号
- 读取配置
- @Value绑定到对象的属性
- @ConfigurationProperties绑定到对象