随笔分类 -  SpringBoot

摘要:@Async 注解的方法被调用后异步执行,注意 SpringBoot 中也需要显式开启 @EnableAsync 原理肯定是动态代理 + BeanPostProcessor 代码:org.springframework.beans.factory.support.AbstractAutowireCa 阅读全文
posted @ 2021-11-18 00:54 YangDanMua 阅读(275) 评论(0) 推荐(0) 编辑
摘要:1. 内部调用不被代理 Cglib生成的代理类继承被代理类,代理类实例持有 target 实例。 相当于 proxy 有个字段 target,然后我们持有 proxy,当调用 proxy.method,代理实例 proxy 当然知道我们调用了哪个方法,于是进行 taget.method 调用,当在 阅读全文
posted @ 2021-11-17 22:29 YangDanMua 阅读(198) 评论(0) 推荐(0) 编辑
摘要:事务的自动代理器为InfrastructureAdvisorAutoProxyCreator,若同时注册多个AbstractAutoProxyCreator子类,可能会存在多处代理的情况。 多次代理的效果如下图所示: 为什么该类会被二次代理呢? @Configuration @EnableTrans 阅读全文
posted @ 2021-11-16 03:39 YangDanMua 阅读(319) 评论(0) 推荐(0) 编辑
摘要:原文:SpringAOP联盟(7)-基础的自动代理(AnnotationAwareAspectJAutoProxyCreator) - 简书 (jianshu.com) DefaultAdvisorAutoProxyCreator和AspectJAwareAdvisorAutoProxyCreato 阅读全文
posted @ 2021-11-16 03:31 YangDanMua 阅读(318) 评论(0) 推荐(0) 编辑
摘要:1. 测试方法 通知类: public class LogMethodBeforeAdvice implements MethodBeforeAdvice { @Override public void before(Method method, Object[] args, Object targ 阅读全文
posted @ 2021-11-16 03:26 YangDanMua 阅读(76) 评论(0) 推荐(0) 编辑
摘要:原文:SpringAOP联盟(5)-MethodInvocation(拦截器的调用) - 简书 (jianshu.com) 在上文中,代理对象创建后,最终的拦截工作都是交给了MethodInvocation。JDK交给了ReflectiveMethodInvocation,而CGLIB交给Cglib 阅读全文
posted @ 2021-11-16 03:16 YangDanMua 阅读(2615) 评论(0) 推荐(0) 编辑
摘要:序:代理对象的创建 无论是AspecJProxyFactory、ProxyFactoryBean、ProxyFactory大体逻辑都是: 填充ProxyCreatorSupport,实际上它是Advised子类,即填充代理配置类(添加Advisor、添加Advice) 得到JDK或者CGLIB的Ao 阅读全文
posted @ 2021-11-16 03:11 YangDanMua 阅读(185) 评论(0) 推荐(0) 编辑
摘要:原文:SpringAOP联盟(2)— Cglib代理流程分析 - 简书 (jianshu.com) 1. 在resources目录下加入logback-test.xml的配置文件 <?xml version="1.0" encoding="UTF-8"?> <configuration> <spri 阅读全文
posted @ 2021-11-16 03:01 YangDanMua 阅读(277) 评论(0) 推荐(0) 编辑
摘要:原文:SpringAOP联盟(1)—Advisor,Advice,Pointcut,Advised、ProxyConfig - 简书 (jianshu.com) 代理对象生成 @Test public void testProxyFactory() { Person person = new Per 阅读全文
posted @ 2021-11-16 02:35 YangDanMua 阅读(191) 评论(0) 推荐(0) 编辑
摘要:原文:聊聊Spring的AOP实现原理 - 简书 (jianshu.com) Spring版本5.3.x AOP 的基本概念 AOP(Aspect Oriented Programming)是基于切面编程的,可无侵入的在原本功能的切面层添加自定义代码,一般用于日志收集、权限认证等场景。 在了解AOP 阅读全文
posted @ 2021-11-16 01:38 YangDanMua 阅读(52) 评论(0) 推荐(0) 编辑
摘要:参考/原地址:HandlerMethodArgumentResolver(二):Map参数类型和固定参数类型【享学Spring MVC】 - 云+社区 - 腾讯云 (tencent.com) 前面介绍了Spring MVC用于处理入参的处理器:HandlerMethodReturnValueHand 阅读全文
posted @ 2021-11-15 10:50 YangDanMua 阅读(42) 评论(0) 推荐(0) 编辑
摘要:参考:HandlerMethodArgumentResolver(一):Controller方法入参自动封装器(将参数parameter解析为值)【享学Spring MVC】 - 云+社区 - 腾讯云 (tencent.com) HandlerMethodArgumentResolver 策略接口: 阅读全文
posted @ 2021-11-15 10:29 YangDanMua 阅读(241) 评论(0) 推荐(0) 编辑
摘要:一、使用 1. 继承 HandlerInterceptor public interface HandlerInterceptor { // Handler 被调用前执行, 返回 false 则不再向下执行 default boolean preHandle(HttpServletRequest r 阅读全文
posted @ 2021-11-14 01:53 YangDanMua 阅读(58) 评论(0) 推荐(0) 编辑
摘要:源码版本 Spring5.3.x,SpringBoot版本2.5.x 仅讨论 RequestMappingHandlerMapping 这个处理注解的处理器映射器 一、自动配置 既然使用了SpringBoot,SpringMVC相关的东西肯定是被自动配置了的 1. WebMvcAutoConfigu 阅读全文
posted @ 2021-11-14 00:32 YangDanMua 阅读(346) 评论(0) 推荐(0) 编辑
摘要:一、SpringApplication 构造 run方法启动 public class SpringApplication { public static ConfigurableApplicationContext run(Class<?> primarySource, String... arg 阅读全文
posted @ 2021-10-24 01:56 YangDanMua 阅读(492) 评论(0) 推荐(0) 编辑
摘要:一、相关的几个注解 @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeF 阅读全文
posted @ 2021-10-22 20:36 YangDanMua 阅读(195) 评论(0) 推荐(0) 编辑
摘要:从自动配置开始看一下 组合注解@SpringBootApplication中的注解@EnableAutoConfiguration @Import(AutoConfigurationImportSelector.class) public @interface EnableAutoConfigura 阅读全文
posted @ 2021-10-22 16:20 YangDanMua 阅读(229) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示