Spring
文章平均质量分 69
介绍Spring的使用技巧
指尖凉
生活明朗,万物可爱,人间值得,未来可期。
展开
-
Spring扩展之HandlerMethodArgumentResolver(自定义请求参数解析器)
文章目录作用执行时机应用作用HandlerMethodArgumentResolver 是请求参数解析器,不管你是要获取Cookie中的值,Header中的值,JSON格式的数据,URI中的值,还是请求体中的数据,Spring都提供了相对应的参数解析器来提取参数。Spring默认提供了26中参数解析器,比如我们最常用的参数注解 @RequestParam 就是由 RequestParamMethodArgumentResolver 解析的,PathVariableMethodArgumentResolv原创 2022-05-02 11:04:07 · 3002 阅读 · 0 评论 -
Spring扩展之ApplicationContextAwareProcessor和Aware
作用该类实现了BeanPostProcessor接口,是一个bean后置处理器,是将 ApplicationContext 传递给实现EnvironmentAware 、 EmbeddedValueResolverAware 、 ResourceLoaderAware 、 ApplicationEventPublisherAware 、MessageSourceAware和 ApplicationContextAware接口的BeanPostProcessor实现。执行时机既然是BeanPostPro原创 2022-04-14 19:12:43 · 258 阅读 · 0 评论 -
Spring扩展之BeanDefinitionRegistryPostProcessor
作用BeanDefinitionRegistryPostProcessor 是 Spring 的扩展点之一。BeanDefinitionRegistryPostProcessor 实现了BeanFactoryPostProcessor 接口,所以它可以实现对 BeanDefinition 的修改。当然BeanDefinitionRegistryPostProcessor 是对 BeanFactoryPostProcessor 功能的扩展,可以动态注册 BeanDefinition,不仅是普通的 bean的原创 2022-04-14 19:11:04 · 1388 阅读 · 0 评论 -
Spring扩展之BeanFactoryPostProcessor
作用BeanFactoryPostProcessor,BeanFactory后置处理器是 Spring 的扩展点之一。通过自定义 BeanFactoryPostProcessor 可以实现对 BeanDefinition 的修改。执行入口BeanFactoryPostProcessor 的执行入口在容器的刷新方法refresh中@Overridepublic void refresh() throws BeansException, IllegalStateException { sync原创 2022-04-14 19:08:46 · 730 阅读 · 0 评论 -
Spring扩展之BeanPostProcessor
作用BeanPostProcessor,顾名思义是bean后置处理器,是 Spring 的扩展点之一。通过自定义 BeanPostProcessor 可以实现对 Bean 的修改,用于在bean实例化后,要初始化的前后对bean进行处理public interface BeanPostProcessor { /** * 在初始化前调用 */ @Nullable default Object postProcessBeforeInitialization(Object bean, Stri原创 2022-04-14 17:02:21 · 1217 阅读 · 0 评论 -
Spring扩展之@Import 和 ImportSelector 接口
简介/* * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * htt原创 2022-04-14 11:21:39 · 783 阅读 · 0 评论 -
Spring扩展之 @Import 和 ImportBeanDefinitionRegistrar 接口
简介ImportBeanDefinitionRegistrar,该接口主要用来注册beanDefinition。很多三方框架集成Spring 的时候,都会通过实现该接口,配合@Import注解注册特定的bean到spring 容器中,比如开启Feign的@EnableFeignClients。还有一些spring自身的@Enable* 注解,也是通过该方式注册bean定义的,比如@EnableAspectJAutoProxy。使用方式自定义一个ImportBeanDefinitionRegistrar原创 2022-04-14 15:07:04 · 1398 阅读 · 0 评论