Spring枯燥无味的一些核心类
ApplicationContextCentral interface to provide configuration for an application. This is read-only while the application is running.
为应用程序提供配置的中央接口。在应用程序运行时,这是只读的,所以一旦启动我们就不能修改上下文了 . SpringApplication #ConfigurableApplicationContext 方法: protected ConfigurableApplicationContext createApplicationContext() { Class<?> contextClass = this.applicationContextClass; ....... 省略 return (ConfigurableApplicationContext) BeanUtils.instantiateClass(contextClass); }
所以Spring-Boot返回的 ApplicationContext 是一个 ConfigurableApplicationContext ,所以后期我们可以强转类型 BeanDefinitionA BeanDefinition describes a bean instance, which has property values, constructor argument values, and further information supplied by concrete implementations.
描述了一个bean实例,它具有属性值、构造函数参数值和由具体实现提供的进一步信息。就是一个Bean的元信息. BeanDefinitionRegistryInterface for registries that hold bean definitions, This is the only interface in Spring"s bean factory packages that encapsulates registration of bean definitions. The standard BeanFactory interfaces only cover access to a fully configured factory instance.
这是Spring的bean factory包中唯一封装bean定义注册的接口。包含bean定义的注册中心的接口 BeanFactoryThe root interface for accessing a Spring bean container.
用于访问Spring bean容器的根接口。 FactoryBeanInterface to be implemented by objects used within a BeanFactory which are themselves factories for inpidual objects. If a bean implements this interface, it is used as a factory for an object to expose, not directly as a bean instance that will be exposed itself.
主要是用户来自定义实例化bean 的 , 可以自定义解析方式之类的 EnvironmentInterface representing the environment in which the current application is running.
表示当前应用运行的环境 , 这个环境可以说是一大堆配置信息 , 包括我们的application.properties文件里的,和一堆系统的,和自定义实现的 public interface Environment extends PropertyResolver {}
它继承了 PropertyResolver ,代表他可以设置 PropertyResolver ,就是一堆的配置信息 (环境信息). DefaultListableBeanFactorySpring"s default implementation of the ConfigurableListableBeanFactory and BeanDefinitionRegistry interfaces: a full-fledged bean factory based on bean definition metadata, extensible through post-processors.
Spring的ConfigurableListableBeanFactory和BeanDefinitionRegistry接口的默认实现 : 一个完全成熟的基于bean定义元数据的bean工厂,可通过后处理器扩展。
它可以说我我们的 spring工厂 ,里面包含了所有的元信息 EnvironmentPostProcessorAllows for customization of the application"s Environment prior to the application context being refreshed. EnvironmentPostProcessor implementations have to be registered in META-INF/spring.factories, using the fully qualified name of this class as the key.
允许在刷新应用程序上下文之前自定义应用程序环境,启动的很早 必须在META-INF/spring中注册EnvironmentPostProcessor实现类,使用该类的完全限定名作为键。 void postProcessEnvironment(ConfigurableEnvironment environment,SpringApplication application) 可以获取启动时的 environment 和 application EnvironmentAwareInterface to be implemented by any bean that wishes to be notified of the Environment that it runs in.
这个接口可以被任何bean使用,希望通知env在运行中需要做什么 void setEnvironment(Environment environment); 可以获取 Environment 对象 ApplicationContextInitializerCallback interface for initializing a Spring ConfigurableApplicationContext prior to being refreshed.
用于在刷新(refresh())初始化Spring ConfigurableApplicationContext之前,的回调接口.
这是一个用来初始化Spring ConfigurableApplicationContext 应用上下文的回调接口,设定的调用时机是在ConfigurableApplicationContext#refresh() 调用之前。void initialize(C applicationContext); 可以获取 spring启动时的上下文对象 ,就是 ConfigurableApplicationContext .ImportBeanDefinitionRegistrarInterface to be implemented by types that register additional bean definitions when processing @Configuration classes. Useful when operating at the bean definition level (as opposed to @Bean method/instance level) is desired or necessary.
Along with @Configuration and ImportSelector, classes of this type may be provided to the @Import annotation (or may also be returned from an ImportSelector).
通常与 @Import 注释使用 , 下面举个栗子@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Documented @Import(ApolloConfigRegistrar.class) public @interface EnableApolloConfig { String[] value() default {ConfigConsts.NAMESPACE_APPLICATION}; int order() default Ordered.LOWEST_PRECEDENCE; }public class ApolloConfigRegistrar implements ImportBeanDefinitionRegistrar { @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { // 1. importingClassMetadata 可以获取 @EnableApolloConfig 的注解的元信息 , 比如字段属性 // 例如 : importingClassMetadata.getAnnotationAttributes(EnableApolloConfig.class.getName()) // 2.registry可以手动注册一个bean ,需要BeanDefinition,和类信息 BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(NoRegisterService.class).getBeanDefinition(); registry.registerBeanDefinition("noRegisterService", beanDefinition); } }
// 主要方法 public void registerBeanDefinitions( AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry); 可以获取 注解类的元信息 , 自定义注解可以BeanDefinitionRegistryPostProcessorExtension to the standard BeanFactoryPostProcessor SPI, allowing for the registration of further bean definitions before regular BeanFactoryPostProcessor detection kicks in.
扩展标准的BeanFactoryPostProcessor SPI,允许在常规的BeanFactoryPostProcessor检测开始之前注册更多的bean定义。 void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException;
在应用程序上下文的标准初始化之后修改它的内部bean定义注册表。所有常规bean定义都已加载,但还没有实例化任何bean。这允许在下一个后处理阶段开始之(BeanFactoryPostProcessor)前添加更多的bean定义. BeanFactoryPostProcessorAllows for custom modification of an application context"s bean definitions, adapting the bean property values of the context"s underlying bean factory.
允许自定义修改应用程序上下文的bean定义,调整上下文的底层bean工厂的bean属性值。 此时已经上下文启动好了.但是bean还没有被实例化 , 可以获取bean的 BeanDefinition , void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;
他的实现类 : PropertyResourceConfigurer 可以快速的使用,并且简单的使用BeanPostProcessorFactory hook that allows for custom modification of new bean instances,
*允许自定义修改新的bean实例, * 可以对bean 进行一些动态的修改 , 在程序运行后 , public interface BeanPostProcessor { default Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } default Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } }@ImportIndicates one or more @Configuration classes to import.
Provides functionality equivalent to the element in Spring XML. Allows for importing @Configuration classes, ImportSelector and ImportBeanDefinitionRegistrar implementations, as well as regular component classes (as of 4.2; analogous to AnnotationConfigApplicationContext.register).
指示要导入的一个或多个@Configuration类。提供与Spring XML中的元素相同的功能。允许导入@Configuration类,ImportSelector和ImportBeanDefinitionRegistrar实现,以及常规组件类(从4.2;类似于AnnotationConfigApplicationContext.register)。也就四种 .. .. . . .
外贸公司没有网站怎么做外贸?也可以做,照样是开发客户,在各大平台上宣传产品。但是,还是投资一个吧,便宜的一两千就可以买够三年的使用权。外贸开发本就是概率低的事情,好不容易找到客户邮箱,发出去邮件,客户想了解一
一切来得那么突然,iPhone13最新价格确认,网友吐槽还是买早了如今智能手机的售价在不断地升高,超过5000元的价格已经是成为了常态,但对于如今的两个阵营中的高端旗舰,相比较之下还是iPhone更加受欢迎一些,此前还有华为的高端旗舰能够和iPh
骁龙8Gen1发布,首批搭载品牌已官宣,OPPO旗舰新品明年1季度搭载12月1日,高通2021技术峰会如约而至,正式发布了骁龙8Gen1处理器,第3代骁龙8cx计算平台第3代骁龙7c计算平台以及第1代骁龙G3x游戏平台。其中,骁龙8Gen1处理器采用
你认为滴滴美国退市和联想有关系吗?有其父必有其女,老父亲侵吞国有资产无数,女儿出卖国家机密一点也不含糊。不管在美上市还是回归香港,都改不了狼子野心,遗传基因中满满的賊胆,离这家人远点,免得粘上霉气知道一点其中内幕的
你用的跑步软件是什么?在用的有五款产品,华为运动健康,keep,咕咚,悦跑圈,悦动圈。手机是华为的,自带的华为运动健康APP,也可以连接华为运动手表,手环来使用keep,安装了好久了,以前主要运来健身运
平价蓝牙耳机选哪个?平价蓝牙耳机可以根据价位来选择品牌,从QCYFIIL漫步者万魔小米等品牌中取舍。下面两款蓝牙耳机可以作为参考1。QCYT11一款圈铁蓝牙耳机,动圈加动铁设计。大多数的蓝牙耳机是动圈
氢能源爆发,今天大涨看它们(名单)昨天大盘最后一小时放量上涨,外围股市普遍下跌,美股三大股指跌幅均超过1。今天大盘应该低开,下探时关注3560点附近的支撑,强支撑在3546点附近回抽时关注3582点附近的压力,强压
夏末Python背景知识1989,为了度过圣诞假期,Guido开始编写Python语言编译器。Python这个名字来自Guido的喜爱的电视连续剧蒙蒂蟒蛇的飞行马戏团。他希望新的语言Python能够满足他
K8S搭建搭建DNS用于K8S各节点解析本次使用5台centos7的服务器CRDL242A10。1。71。242CRDL243A10。1。71。243CRDL244A10。1。71。244CRDL245A10。1。71。
如何看待胡锡进对联想事件前后判若两人的表态?我一开始就不喜欢胡锡进,我不迷信但是胡锡进的面相看上去就是标准的奸诈之徒!这种面相之人绝对是墙头草两面人,这种人没有初心,这种人心机很重,这一次完全暴露了其本质,说太多冠冕堂皇侃侃
以前那么好用的廉价圆珠笔为什么突然消失了?因为减低产量了。之前,圆珠笔钢珠所用的特种钢材,全世界只有两个国家生产瑞士和日本。圆珠笔尖的加工设备也只有两个国家生产瑞士和德国。其他国家为什么不生产?因为不值得费那个劲,价值太低