随笔分类 -  Spring

Spring 高级 工厂后处理器模拟实现-@Bean
摘要:一、初步扫描到所有被@Bean注解标注的方法的信息 package com.mangoubiubiu.show.a05; import com.mangoubiubiu.show.a05.component.ComponentScanPostProcessor; import lombok.exte
34
0
0
Spring 高级 工厂后处理器模拟实现组件扫描-模拟ComponentScan 进阶
摘要:一、自定义Bean 后处理器 Processor package com.mangoubiubiu.show.a05.component; import com.mangoubiubiu.show.a05.Config; import org.springframework.beans.BeansE
32
0
0
Spring 高级 工厂后处理器模拟实现组件扫描(一)
摘要:一、代码 package com.mangoubiubiu.show.a05; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.mapper.MapperScannerConfigurer; import org.springf
36
0
0
Spring 高级 BeanFactory 后处理器 - BeanFactory 后处理器的作用
摘要:一、ConfigurationClassPostProcessor 1、示范代码 Bean2 package com.mangoubiubiu.show.a05.component; import com.mangoubiubiu.show.a05.Bean1; import org.slf4j.L
43
0
0
Spring 高级 @Autowired bean 后处理器运行分析
摘要:上篇:https://www.cnblogs.com/mangoubiubiu/p/16591665.html 知道了 AutowiredAnnotationBeanPostProcessor 执行依赖注入的时候,实际上是先调用了postProcessProperties方法,而postProces
124
0
0
Spring 高级 AutowiredAnnotationBeanPostProcessor 运行分析
摘要:1、AutowiredAnnotationBeanPostProcessor 运行分析 AutowiredAnnotationBeanPostProcessor 的作用:AutowiredAnnotationBeanPostProcessor 解析 @Autowired与 @Value 执行时机 在
145
0
0
Spring 高级 常见的Bean 后处理器
摘要:一、代码 package com.mangoubiubiu.show.a04; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.A
108
0
0
Spring高级 事件监听器 (三)@EventListener 解析原理
摘要:一、代码 1、自定义注解 package com.mangoubiubiu.annotation; import java.lang.annotation.*; @Target(value = {ElementType.TYPE,ElementType.METHOD,ElementType.FIEL
460
0
0
Spring高级 事件监听器 (二)利用线程池异步发送事件
摘要:publishEvent 底层调用了一个SimpleApplicationEventMulticaster 来发布事件,属性有一个Executor 可以用来设置异步的方式 一、设置线程池 package com.mangoubiubiu.conf; import org.springframewor
467
0
0
Spring高级 事件监听器 (一)
摘要:事件监听器的两种方式 实现 ApplicationListener 接口 根据接口泛型确定事件类型 @EventListener 标注监听方法 根据监听器方法参数确定事件类型 解析时机:在 SmartInitializingSingleton(所有单例初始化完成后),解析每个单例 bean 一、 实
191
0
1
Spring 高级 Bean 的生命周期
摘要:Bean 的生命周期 一个受 Spring 管理的 bean,生命周期主要阶段有 创建:根据 bean 的构造方法或者工厂方法来创建 bean 实例对象 依赖注入:根据 @Autowired,@Value 或其它一些手段,为 bean 的成员变量填充值、建立关系 初始化:回调各种 Aware 接口,
41
0
0
Spring高级--容器实现-ApplicationContext实现(二)
摘要:一、AnnotationConfigServletWebServerApplicationContext Spring boot 中 servlet web 环境容器(新) 1、场景利用AnnotationConfigServletWebServerApplicationContext 手写一个简单
98
0
0
Spring高级--容器实现-ApplicationContext实现(一)
摘要:一、ClassPathXmlApplicationContext:从类路径查找 XML 配置文件,创建容器(旧) 1、代码 /** * 较为经典的容器,基于classpath 下xml格式配置文件来创建 */ private static void testClassPathXmlApplicati
79
0
0
Spring高级-容器实现-BeanFactory后处理器排序(二)
摘要:一、@Autowired 和 @Resource(name = "bean4") 同时存在,会优先注入哪个bean? 1、代码 package com.mangoubiubiu.show; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logg
59
0
0
Spring高级-容器实现-BeanFactory后处理器排序(一)
摘要:一、开胃菜:入门级面试题:如果一个接口有多个实现类,想取到其中某一个Bean怎么进行一个依赖注入 1、代码 package com.mangoubiubiu.show; import lombok.extern.slf4j.Slf4j; import org.slf4j.LoggerFactory;
63
0
0
Spring高级-容器实现-BeanFactory实现的特点
摘要:一、DefaultListableBeanFactory DefaultListableBeanFactory,是 BeanFactory 最重要的实现,像控制反转和依赖注入功能,都是它来实现 1、需求一:往DefaultListableBeanFactory里面 注册一个组件 package co
54
0
0
Spring高级-容器接口-ApplicationContext的功能
摘要:ApplicationContext的实现类拥有不同的能力 EnvironmentCapable:整合 Environment 环境(能通过它获取各种来源的配置信息) MessageSource: 国际化,提供一些针对不同语言翻译的能力 ResourcePatternResolver:通配符方式获取
168
0
0
Spring高级-容器接口-初识BeanFactory
摘要:一 容器接口 ConfigurableApplicationContext 1、代码 package com.mangoubiubiu.show; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringAppl
59
0
0
点击右上角即可分享
微信分享提示
深色
回顶
收起