我的SpringBoot实战记
事件:
使用Springboot开发
目的:
最近用Springboot写了个小工具,其实不在于工具的实际价值,主要学习一下Springboot的使用罢了;
上班时使用Springboot都是在已搭建好的框架上,只进行业务的开发,深度着实有点浅了...
源码:
https://github.com/layerdo/demo
Point:
- 拦截器/过滤器/监听器
1.1. xxFilter implements Filter
xxInterceptor implements HandlerInterceptor
MyInterceptorConfig implements WebMvcConfigurer(请使用此新接口,就接口是过时的,甚至无法使用,血的教训) - 如何配置其他工具
2.1. 配置文件(.yml 或 .xml)中进行配置
2.2. @Configuration注解进行配置 - swagger
- mybatis 及相关自动生成工具
- @ControllerAdvice 和 @RestControllerAdvice的使用
及 配合ResponseBodyAdvice接口/@ExceptionHandler 实现返回值自动封装。(也可以做数据加密之类,总之controller层返回后对数据再处理)
未完待续...