Book
关于
标签
分类
读书笔记
人性的枷锁
酒国
消息队列
kafka
rocketmq
rabbitmq
redis
Spring
控制反转(IOC)/依赖注入(DI)
ApplicationContext 容器
SSM 框架整合
Spring Boot
应用上下文配置类(ConfigurableApplicationContext)
核心注解(@SpringBootApplication)
自动配置类加载(@EnableAutoConfiguration)
自动导入包(@AutoConfigurationPackage)
类导入(@Import)
条件导入(@Conditional)
全局配置(application.properties)
多环境配置切换
属性加密
日志配置
属性松散绑定规则
全局配置属性注入
逐个注入(@Value)
批量注入(@ConfigurationProperties @EnableConfigurationProperties)
请求拦截(HandlerInterceptor & Filter & @WebFilter)
前后端数据交互对接
全局响应体处理器(ResponseBodyAdvice)
取消封装
响应体空值处理
全局异常处理类
事务
TransactionManager 事务管理器
事务属性
事务状态
声明式事务(xml & 注解)
配置xml方式
创建事务管理器
使用注解方式(@Transactional)
环绕通知使用事务(@Around)
编程式事务(TransactionTemplate & PlatformTransactionManager)
面试题
1.Java基础面试题
2.Spring 面试题
3.数据库面试题
4.中间件面试题
5.运维面试题
6.场景题
7.算法题
大语言模型
运维
软件测评
开源测评
系统设计最佳实践
QA
安装部署
全局异常处理类
在实际开发中,我们通常根据业务逻辑自定义异常处理,组合 @RestControllerAdvice 和 @ExceptionHandler 注解对异常进行处理,自定义异常通常会包含业务异常和系统异常 示例 BusinessException.java public class BusinessException ext ...
2022-09-28
Spring Boot
取消封装
如果特定业务中需要避免数据被全局响应体处理器封装,可以自定义一个注解作用于方法上,同时在 ResponseBodyAdvice.supports() 中对该注解进行过滤 示例 IgnoreResponseAdvice.java @Documented @Inherited @Target({ElementType.ANNOTATION ...
2022-09-28
Spring Boot
响应体空值处理
当请求接口不返回数据时,封装后响应体传递的 JSON 数据中 data 的值就会显示为 null,整体上看起来并不协调,我们可以对 data 的空值进行处理,转化为空符串 我们可以自定义一个 Jackson 配置类,在配置类中使用 Jackson2ObjectMapperBuilder 来建一个 ObjectMapper 用于获取当 ...
2022-09-28
Spring Boot
全局响应体处理器(ResponseBodyAdvice)
封装响应体依旧需要在控制层频繁使用 Result.success(),Result.fail() 手动封装响应体返回,这造成了代码的大量耦合,并且也污染了业务处理的代码逻辑 SpringMVC 4.1 后提供了 ResponseBodyAdvice 接口用于拦截 Controller 方法的返回值,它允许在执行 @ResponseBody 后 ...
2022-09-28
Spring Boot
前后端数据交互对接
默认情况下 SpringBoot 对返回的数据有以下对应的返回类型,如果没有对数据进行统一,前端获取到数据时就不能很好的进行处理 因此在以前的开发中我们会定义统一的 Result 响应体和 ResultCode 错误码,使用 Result.success(),Result.fail() 来封装成统一的响应体返回数 ...
2022-09-28
Spring Boot
请求拦截(HandlerInterceptor & Filter & @WebFilter)
Spring Boot中有两种拦截网页方式,可以对未登录的请求进行拦截,防止用户跳过登录,直接进入界面 Filter 过滤器 HandlerInterceptor 拦截器 ...
2022-09-28
Spring Boot
批量注入(@ConfigurationProperties @EnableConfigurationProperties)
@ConfigurationProperties中的前缀属性定义了哪些外部属性将绑定到类的字段上 参数 描述 ...
2022-09-28
Spring Boot
逐个注入(@Value)
@Value是spring中的属性注解,使用@Value注解可以取出全局配置中的属性,注入到参数中 在application.properties中添加自定义属性 user.name=admin user.password=123456 示例 @RestController public class UserCo ...
2022-09-28
Spring Boot
全局配置属性注入
Spring boot注入全局配置属性有两种方法 使用@Value逐个注入 使用@ConfigurationProperties批量注入 注 @Value直接在Controller类的参数上注入使用 @Conf ...
2022-09-28
Spring Boot
属性松散绑定规则
Spring Boot 属性名绑定比较松散。 以下属性 key 都是等价的: 属性 方式 ...
2022-09-28
Spring Boot
1
2
3
>