1.注解用过吗?常用的注解有哪些?
前后端开发常用的注解:
控制层(Controller):
@Api (io.swagger.annotations.Api):用于生成接口文档方便开发。@Slf4j(lombok.extern.slf4j.Slf4j):用于日志输出@RestController(org.springframework.web.bind.annotation.*):相当于@Controller + @ResponseBody,作用就是返回给前端的是JSON格式的数据。
@RequestMapping(org.springframework.web.bind.annotation.*):用来处理请求映射的注解,用在类和方法上。
@Validated(org.springframework.validation.annotation.Validated):用于校验数据
@Autowired(org.springframework.web.bind.annotation.*)用于注入属性
@Resources (org.springframework.web.bind.annotation.*) 用于注入bean
@PostMapping(org.springframework.web.bind.annotation.*) 用于访问的url
@RequestBody(org.springframework.web.bind.annotation.*) 用于配置参数
服务层(Service)
@Service(org.springframework.stereotype.Service) 用于注入bean
@Autowired(org.springframework.web.bind.annotation.*)用于注入属性
@Value(org.springframework.web.bind.annotation.*) 用于注入配置文件的数据
DAO层(Mapper)
@Mapper(org.apache.ibatis.annotations.Mapper) 用于注入bean
@Param(org.apache.ibatis.annotations.Param) 用于方法的参数设置
2.消息中间件有哪些,使用的场景:
Redis:用于数据的缓存读取,分布式锁
Zookeeper:用于服务注册中心,保持服务的一致性
ElasticSearch:Elasticsearch提供了全文搜索的功能,适用于商品搜索
ElasticJob:用于定时任务的编写
Mongdb:用于图片存储
3.多线程中start与run方法的使用?
start() : 它的作用是启动一个新线程,新线程会执行相应的run()方法。start()不能被重复调用。 run() : run()就和普通的成员方法一样,可以被重复调用。单独调用run()的话,会在当前线程中执行run(),而并不会启动新线程.
4.使用多线程的场景有哪些?
Excel数据导入,批量导出、批量下载,数据文件解析入库。
5. mysql索引什么情况下失效?
(1)where 子句中使用!=或<>操作符
(2)where子句子中对字段进行null值判断
(3)where子句中使用 like '%%'
(4) in 和 not in
(5)where 子句对字段进行函数操作
6.使用explain查看索引时你一般关注那些字段?作用是什么?
id:选择标识符
作用:是SQL执行的顺序的标识,SQL从大到小的执行
select_type:表示查询的类型。
作用:表示查询中每个select子句的类型
(1) SIMPLE(简单SELECT,不使用UNION或子查询等)
(2) PRIMARY(子查询中最外层查询,查询中若包含任何复杂的子部分,最外层的select被标记为PRIMARY)