spring bean的加载

Spring源码——bean的加载 前言 内容主要参考自《Spring源码深度解析》一书,算是读书笔记或是原书的补充。进入正文后可能会引来各种不适,毕竟阅读源码是件极其痛苦的事情。 本文主要涉及书中第五章的部分,依照书中内容以及个人理解对Spring进行了注释,详见Github仓库:https://github.com/MrSorrow/spring-framework 在前几篇文章中,我们已经完成了将XML配置文件的信息转换为 B... 阅读详情

   BeanFactory bg = new XmlBeanFactory(new ClassPathResource("bean.xml"));

  MyTestBean bean = (MyTestBean)bg.getBean("myTestBean");

上篇bean注册完成后,存入map中后,当需要实例化某对象时,调取DefaultListableFactory 类中,getBean方法获取对象;

1 getBean代码流程

@Override
	public <T> T getBean(Class<T> requiredType, Object... args) throws BeansException {
		Assert.notNull(requiredType, "Required type must not be null");
		String[] beanNames = getBeanNamesForType(requiredType);
		if (beanNames.length > 1) {
			ArrayList<String> autowireCandidates = new ArrayList<String>();
			for (String beanName : beanNames) {
				if (!containsBeanDefinition(beanName) || getBeanDefinition(beanName).isAutowireCandidate()) {
					autowireCandidates.add(beanName);
				}
			}
			if (autowireCandidates.size() > 0) {
				beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
			}
		}
		if (beanNames.length == 1) {
			return getBean(beanNames[0], requiredType, args);
		}
		else if (beanNames.length > 1) {
			Map<String, Object> candidates = new HashMap<String, Object>();
			for (String beanName : beanNames) {
				candidates.put(beanName, getBean(beanName, requiredType, args));
			}
			String primaryCandidate = determinePrimaryCandidate(candidates, requiredType);
			if (primaryCandidate != null) {
				return getBean(primaryCandidate, requiredType, args);
			}
			String priorityCandidate = determineHighestPriorityCandidate(candidates, requiredType);
			if (priorityCandidate != null) {
				return getBean(priorityCandidate, requiredType, args);
			}
			throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
		}
		else if (getParentBeanFactory() != null) {
			return getParentBeanFactory().getBean(requiredType, args);
		}
		else {
			throw new NoSuchBeanDefinitionException(requiredType);
		}
	}
protected <T> T doGetBean(
			final String name, final Class<T> requiredType, final Object[] args, boolean typeCheckOnly)
			throws BeansException {

		final String beanName = transformedBeanName(name);
		Object bean;

		// Eagerly check singleton cache for manually registered singletons.
                //直接尝试从缓存中获取singletoFactories中ObjectFactory中获取
		Object sharedInstance = getSingleton(beanName);
		if (sharedInstance != null && args == null) {
			if (logger.isDebugEnabled()) {
				if (isSingletonCurrentlyInCreation(beanName)) {
					logger.debug("Returning eagerly cached instance of singleton bean '" + beanName +
							"' that is not fully initialized yet - a consequence of a circular reference");
				}
				else {
					logger.debug("Returning cached instance of singleton bean '" + beanName + "'");
				}
			}
			bean = getObjectForBeanInstance(sharedInstance, name, beanName, null);
		}

		else {
			// Fail if we're already creating this bean instance:
			// We're assumably within a circular reference.
			if (isPrototypeCurrentlyInCreation(beanName)) {
				throw new BeanCurrentlyInCreationException(beanName);
			}

			// Check if bean definition exists in this factory.
			BeanFactory parentBeanFactory = getParentBeanFactory();
			if (parentBeanFactory != null && !containsBeanDefinition(beanName)) {
				// Not found -> check parent.
				String nameToLookup = originalBeanName(name);
				if (args != null) {
					// Delegation to parent with explicit args.
					return (T) parentBeanFactory.getBean(nameToLookup, args);
				}
				else {
					// No args -> delegate to standard getBean method.
					return parentBeanFactory.getBean(nameToLookup, requiredType);
				}
			}

			if (!typeCheckOnly) {
				markBeanAsCreated(beanName);
			}

			try {
				final RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
				checkMergedBeanDefinition(mbd, beanName, args);

				// Guarantee initialization of beans that the current bean depends on.
				String[] dependsOn = mbd.getDependsOn();
				if (dependsOn != null) {
					for (String dependsOnBean : dependsOn) {
						if (isDependent(beanName, dependsOnBean)) {
							throw new BeanCreationException(mbd.getResourceDescription(), beanName,
									"Circular depends-on relationship between '" + beanName + "' and '" + dependsOnBean + "'");
						}
						registerDependentBean(dependsOnBean, beanName);
						getBean(dependsOnBean);
					}
				}

				// Create bean instance.
				if (mbd.isSingleton()) {
					sharedInstance = getSingleton(beanName, new ObjectFactory<Object>() {
						@Override
						public Object getObject() throws BeansException {
							try {
								return createBean(beanName, mbd, args);
							}
							catch (BeansException ex) {
								// Explicitly remove instance from singleton cache: It might have been put there
								// eagerly by the creation process, to allow for circular reference resolution.
								// Also remove any beans that received a temporary reference to the bean.
								destroySingleton(beanName);
								throw ex;
							}
						}
					});
					bean = getObjectForBeanInstance(sharedInstance, name, beanName, mbd);
				}

				else if (mbd.isPrototype()) {
					// It's a prototype -> create a new instance.
					Object prototypeInstance = null;
					try {
						beforePrototypeCreation(beanName);
						prototypeInstance = createBean(beanName, mbd, args);
					}
					finally {
						afterPrototypeCreation(beanName);
					}
					bean = getObjectForBeanInstance(prototypeInstance, name, beanName, mbd);
				}

				else {
					String scopeName = mbd.getScope();
					final Scope scope = this.scopes.get(scopeName);
					if (scope == null) {
						throw new IllegalStateException("No Scope registered for scope '" + scopeName + "'");
					}
					try {
						Object scopedInstance = scope.get(beanName, new ObjectFactory<Object>() {
							@Override
							public Object getObject() throws BeansException {
								beforePrototypeCreation(beanName);
								try {
									return createBean(beanName, mbd, args);
								}
								finally {
									afterPrototypeCreation(beanName);
								}
							}
						});
						bean = 
//判断bean是否为factoryBean
getObjectForBeanInstance(scopedInstance, name, beanName, mbd);
					}
					catch (IllegalStateException ex) {
						throw new BeanCreationException(beanName,
								"Scope '" + scopeName + "' is not active for the current thread; " +
								"consider defining a scoped proxy for this bean if you intend to refer to it from a singleton",
								ex);
					}
				}
			}
			catch (BeansException ex) {
				cleanupAfterBeanCreationFailure(beanName);
				throw ex;
			}
		}

		// Check if required type matches the type of the actual bean instance.
		if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
			try {
				return getTypeConverter().convertIfNecessary(bean, requiredType);
			}
			catch (TypeMismatchException ex) {
				if (logger.isDebugEnabled()) {
					logger.debug("Failed to convert bean '" + name + "' to required type [" +
							ClassUtils.getQualifiedName(requiredType) + "]", ex);
				}
				throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
			}
		}
		return (T) bean;
	}

 doGetBean方法主要完成以下任务:

     (1):装换beanName,因此传参的beanName可能是别名,或者FactoryBean,如果是FactoryBean的修饰,则如果是name="&aa",则需要去除&号。

       (2):尝试从缓存中加载单例;由于单例中存在循环依赖问题,为了避免依赖,spring中创建bean的原则是不等bean创建完成,就会把创建bean的ObjectFactory提早曝光到缓存中,一旦下一个bean需要依赖上一个bean,则可以直接使用ObjectFactory;

 (3)bean实例化,从缓存中获取bean,记录的是bean的原始状态,并不是我们想要的最终bean,比如如果对象时实现了FactoryBean接口类,那需要对工厂bean进行处理。

  (4):原型模式依赖检测,如果存在循环依赖,直接抛异常;

  (5):检测parentBeanFactory   为了递归调用父类对象中;

   (6):将存储xml配置信息的GenericBeanDefinition转化为RootBeanDefiniton,后面所有的操作,都是针对RootBeanDefinition;

(7)寻找依赖,别的对象属性;

(8)根据不同的scope进行bean的创建

(9)类型转换;

 2:FactoryBean的使用;

   FactoryBean是spring提供的一种摆脱bean标签配置bean,采用编码的方式返回定制化的bean的一种灵活方式;FactoryBean接口有个方法:getObject,当某个类实现FactoryBean接口类时,当调用getBean方法获取该类对象时,获取的对象不是FactoryBean本身,而是FactoryBean类中的getObject()方法对象,因此这个对象可以自定义实现业务的逻辑代码。spring与mybatis整合时,mapperFactoryBean 与slqSessionFactoryBean均实现了该接口类;以此来实现自己的逻辑;相当于FactoryBean的getObject()代理了getBean方法。

3:从bean的实例中获取对象

当获取bean时,spring会校验当前bean是否为factoryBean,如果是那么需要调用该bean对应的FactoryBean实例中的getObject()作为返回值。而getObjectForBeanInstance方法就是完成这个工作的。

private Object doGetObjectFromFactoryBean(final FactoryBean<?> factory, final String beanName)
			throws BeanCreationException {

		Object object;
		try {
			if (System.getSecurityManager() != null) {
				AccessControlContext acc = getAccessControlContext();
				try {
					object = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
						@Override
						public Object run() throws Exception {
								return factory.getObject();
							}
						}, acc);
				}
				catch (PrivilegedActionException pae) {
					throw pae.getException();
				}
			}
			else {
                                //直接调用getObject方法
				object = factory.getObject();
			}
		}
		catch (FactoryBeanNotInitializedException ex) {
			throw new BeanCurrentlyInCreationException(beanName, ex.toString());
		}
		catch (Throwable ex) {
			throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex);
		}

		// Do not accept a null value for a FactoryBean that's not fully
		// initialized yet: Many FactoryBeans just return null then.
		if (object == null && isSingletonCurrentlyInCreation(beanName)) {
			throw new BeanCurrentlyInCreationException(
					beanName, "FactoryBean which is currently in creation returned null from getObject");
		}
		return object;
	}

 

4:createBean:创建bean

@Override
	protected Object createBean(final String beanName, final RootBeanDefinition mbd, final Object[] args)
			throws BeanCreationException {

		if (logger.isDebugEnabled()) {
			logger.debug("Creating instance of bean '" + beanName + "'");
		}
		// Make sure bean class is actually resolved at this point.
		resolveBeanClass(mbd, beanName);

		// Prepare method overrides.
		try {
			mbd.prepareMethodOverrides();
		}
		catch (BeanDefinitionValidationException ex) {
			throw new BeanDefinitionStoreException(mbd.getResourceDescription(),
					beanName, "Validation of method overrides failed", ex);
		}

		try {
			// Give BeanPostProcessors a chance to return a proxy instead of the target bean instance.
 //AOP实现逻辑			
Object bean = resolveBeforeInstantiation(beanName, mbd);
			
                   if (bean != null) {
				return bean;
			}
		}
		catch (Throwable ex) {
			throw new BeanCreationException(mbd.getResourceDescription(), beanName,
					"BeanPostProcessor before instantiation of bean failed", ex);
		}

		Object beanInstance = doCreateBean(beanName, mbd, args);
		if (logger.isDebugEnabled()) {
			logger.debug("Finished creating instance of bean '" + beanName + "'");
		}
		return beanInstance;
	}

 (1):根据设置class属性或者根据classNme来解析class

(2):对override属性进行标记及验证;主要是lookup-method和replace-method

(3):应用初始化前的后处理器,解析指定bean是否存在初始化前的短路操作

(4):创建bean;

  a:代理bean的创建;其中这段代码:// Give BeanPostProcessors a chance to return a proxy instead of the target bean instance.
Object bean = resolveBeforeInstantiation(beanName, mbd);这里会触发短路操作,如果有代理对象生成就直接返回了,bean创建也就完成了。
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
		Object bean = null;
		if (!Boolean.FALSE.equals(mbd.beforeInstantiationResolved)) {
			// Make sure bean class is actually resolved at this point.
			if (!mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
				Class<?> targetType = determineTargetType(beanName, mbd);
				if (targetType != null) {
					bean = applyBeanPostProcessorsBeforeInstantiation(targetType, beanName);
					if (bean != null) {
						bean = applyBeanPostProcessorsAfterInitialization(bean, beanName);
					}
				}
			}
			mbd.beforeInstantiationResolved = (bean != null);
		}
		return bean;
	}
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName)
			throws BeansException {

		for (BeanPostProcessor bp : getBeanPostProcessors()) {
			if (bp instanceof InstantiationAwareBeanPostProcessor) {
				InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
				Object result = ibp.postProcessBeforeInstantiation(beanClass, beanName);
				if (result != null) {
					return result;
				}
			}
		}
		return null;
	}
@Override
	public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
			throws BeansException {

		Object result = existingBean;
		for (BeanPostProcessor beanProcessor : getBeanPostProcessors()) {
			result = beanProcessor.postProcessAfterInitialization(result, beanName);
			if (result == null) {
				return result;
			}
		}
		return result;
	}
//AbstractAutoProxyCreator 类是xml配置aop创建的核心,后期的@aspectJ注解版的aop其实也是子类对其的继承,AbstractAutoProxyCreator间接实现了BeanPostprocessor接口,对bean进行实例化前后的调用
@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		Object cacheKey = getCacheKey(beanClass, beanName);

		if (beanName == null || !this.targetSourcedBeans.contains(beanName)) {
			if (this.advisedBeans.containsKey(cacheKey)) {
				return null;
			}
			if (isInfrastructureClass(beanClass) || shouldSkip(beanClass, beanName)) {
				this.advisedBeans.put(cacheKey, Boolean.FALSE);
				return null;
			}
		}

		// Create proxy here if we have a custom TargetSource.
		// Suppresses unnecessary default instantiation of the target bean:
		// The TargetSource will handle target instances in a custom fashion.
		if (beanName != null) {
			TargetSource targetSource = getCustomTargetSource(beanClass, beanName);
			if (targetSource != null) {
				this.targetSourcedBeans.add(beanName);
				Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(beanClass, beanName, targetSource);
				Object proxy = createProxy(beanClass, beanName, specificInterceptors, targetSource);
				this.proxyTypes.put(cacheKey, proxy.getClass());
				return proxy;
			}
		}

		return null;
	}

当createBean中短路方法返回的bean不为空时,就会调用baan初始化前后的后处理器应用。这里返回的bean已经不是原来的bean了,为aop代理对象;

 spring中的规则是bean初始化后尽量保证将注册的后处理器的postProcessAfgerInitialization方法应用到该bean中。

B:普通bean的创建:doCreatBean方法;这里主要根据配置信息,选择对应的bean创建方式,如无参构成方式,有参构造方式,根据不同的反射方式创建对象。

Object beanInstance = doCreateBean(beanName, mbd, args);

核心方法

protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd, Object[] args) {
		// Make sure bean class is actually resolved at this point.
		Class<?> beanClass = resolveBeanClass(mbd, beanName);

		if (beanClass != null && !Modifier.isPublic(beanClass.getModifiers()) && !mbd.isNonPublicAccessAllowed()) {
			throw new BeanCreationException(mbd.getResourceDescription(), beanName,
					"Bean class isn't public, and non-public access not allowed: " + beanClass.getName());
		}

		if (mbd.getFactoryMethodName() != null)  {
			return instantiateUsingFactoryMethod(beanName, mbd, args);
		}

		// Shortcut when re-creating the same bean...
		boolean resolved = false;
		boolean autowireNecessary = false;
		if (args == null) {
			synchronized (mbd.constructorArgumentLock) {
				if (mbd.resolvedConstructorOrFactoryMethod != null) {
					resolved = true;
					autowireNecessary = mbd.constructorArgumentsResolved;
				}
			}
		}
		if (resolved) {
			if (autowireNecessary) {
				return autowireConstructor(beanName, mbd, null, null);
			}
			else {
				return instantiateBean(beanName, mbd);
			}
		}

		// Need to determine the constructor...
		Constructor<?>[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
		if (ctors != null ||
				mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR ||
				mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args))  {
			return autowireConstructor(beanName, mbd, ctors, args);
		}

		// No special handling: simply use no-arg constructor.
		return instantiateBean(beanName, mbd);
	}
protected BeanWrapper instantiateBean(final String beanName, final RootBeanDefinition mbd) {
		try {
			Object beanInstance;
			final BeanFactory parent = this;
			if (System.getSecurityManager() != null) {
				beanInstance = AccessController.doPrivileged(new PrivilegedAction<Object>() {
					@Override
					public Object run() {
						return getInstantiationStrategy().instantiate(mbd, beanName, parent);
					}
				}, getAccessControlContext());
			}
			else {
				beanInstance = getInstantiationStrategy().instantiate(mbd, beanName, parent);
			}
			BeanWrapper bw = new BeanWrapperImpl(beanInstance);
			initBeanWrapper(bw);
			return bw;
		}
		catch (Throwable ex) {
			throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Instantiation of bean failed", ex);
		}
	}

 4:返回创建bean后,初始化时会对其类方法初始化,包括1:”激活aware方法,一些感知接口类如beanFactoryAware,ApplicationContextAware等;2:处理器的应用:BeanPostProcessor接口类的实现调用;3:init方法的调用

这里有连个初始化后方法的调用;一个是xml中配置init-method方法。一个是类对象实现InitializingBean接口的实现方法afterProperitySet方法;执行顺序是afterProperitySet,后init-method;

5:注册销毁方法;如destory-metod方法;

 

EDEM在农业机械设计中的实战应用:以谷物收割机优化为例 本文以谷物收割机优化为例,详细阐述了EDEM离散元仿真软件在农业机械设计中的实战应用。通过构建精准的“数字谷物”模型与农机部件动态界面,利用GPU加速完成大规模颗粒系统仿真,有效诊断并解决了籽粒夹带损失与清选负荷不均等田间难题,实现了从仿真分析到田间验证的设计优化闭环。 阅读详情

相关推荐

Zynq7系列DDR3 PCB设计中的阻抗匹配与端接电阻优化策略

本文深入探讨了Zynq7系列SoC在DDR3接口PCB设计中的核心挑战,重点分析了走线阻抗与端接电阻的匹配策略。通过对比官方推荐的40欧姆与工程实践中更通用的50欧姆方案,结合仿真数据揭示了阻抗匹配对信号完整性的决定性影响,并提供了从叠层规划、布线优化到后期验证的完整实战清单,旨在帮助工程师实现高稳定性的高速电路设计。

weixin_29306011的博客 186

已解决错误代码: NoSuchBeanDefinitionException(未找到Bean定义异常)

NoSuchBeanDefinitionException异常通常是由于缺少合适的注解或配置错误而引起的。通过正确标注注解和配置Bean定义,我们可以避免此类异常,并确保Spring容器能够正常管理和注入Bean,提高应用程序的稳定性和可维护性。在使用Spring框架时,理解依赖注入的原理和正确配置Bean定义是非常重要的,这有助于优化代码结构并提高开发效率。

沉淀所学,分享所思,让热爱与成长同行。商务记录AI实战经验,助力开发者快速成长。 热爱AI,希望做出有影响力的技术成果。 技术点亮生活,分享连接价值与机会。 专注AI落地实战,陪你走好技术每一步。 6235

【信创-k8s】银河麒麟V10国防版+鲲鹏/飞腾(arm64架构)在线/离线部署k8s1.30+kubesphere

银河麒麟作为国家核高基专项的重要成果,国防版凭借其卓越的安全性和可靠性,已成为军工领域的首选操作系统。之前我们在适配麒麟V4国防版的过程中已发现诸多安全性要求,而麒麟V10国防版在安全防护等级上又达到了更高的级别。本文将主要演示离线部署,因为军工项目基本不会出现联网场景。即使在线,也可以按离线方式部署,且离线部署由于有私有仓库,不会存在镜像获取不到和丢失情况。

jiaworld的博客 734

NoSuchBeanDefinitionException(未找到Bean定义异常)可能的原因和解决方法

解决方法:确保在获取 Bean 时,使用的是正确的作用域。解决方法:仔细检查代码中获取 Bean 的地方,确保提供的 Bean 名称与实际定义的名称一致。解决方法:确保使用的 ApplicationContext 实现是适用于项目的,并且能够正确加载 Bean。解决方法:检查项目中所有的依赖库和框架版本,确保它们与当前使用的 Spring 版本兼容。解决方法:检查手动注册的 Bean,确保注册的名称与代码中使用的名称一致。解决方法:确保所有的 Bean 名称在上下文中是唯一的,避免名称冲突。

Java开源程序猿 8987

MacBook上玩转国民技术N32G430:从零搭建ARM开发环境(VSCode + pyOCD)

本文详细介绍了在MacBook上搭建国民技术N32G430的ARM开发环境,涵盖VSCode配置、pyOCD调试及一键编译烧录全流程。通过Homebrew安装工具链、配置Python环境及VSCode插件,开发者可在MacOS高效开发嵌入式应用,特别适合国产芯片N32G430的开发者参考。

weixin_30614109的博客 441

Python RK3588 MPP 8路视频硬解码!全体目光向我看齐!

本文重写了官方demo、加入了Zlmediakit进行拉流并通过pybind11将代码封装成so库,现在,在python中直接通过import的方式,就能完成基础的拉流解码操作,目前支持8路拉流解码!!!

m0_46303486的博客 4888

spring refresh()方法详解6之finishBeanFactoryInitialization(beanFactory)

/** * 初始化所有非懒加载的单例bean */ protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory beanFactory) { // 1.初始化此上下文的转换服务 if (beanFactory.containsBean(CONVERSION_SERVICE_BEAN_NAME) && beanFactory.isTypeMatch(CONVERSIO..

luo_mu_hpu的博客 277

别再手动建模了!用Simscape Multibody Link一键导入SolidWorks装配体到Simulink

本文介绍了如何利用Simscape Multibody Link插件将SolidWorks装配体一键导入Simulink,实现CAD到仿真的无缝衔接。该技术显著提升机械系统设计与控制效率,特别适用于工业机器人、车辆悬架等复杂机构的动力学分析。文章详细解析了插件安装、模型导出优化及仿真验证的全流程,帮助工程师摆脱手动建模的低效工作模式。

weixin_27256197的博客 472

license 移除

import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.Bean

一种感觉的博客 1394

S7-1500——(一)西门子PLC编程从入门到精通4、SCL间接寻址

学习目标是在掌握博途平台SCL编程语言的基本使用基础之上,进一步了解SCL语言环境下的间接寻址过程,初步具备编写复杂控制程序的能力;在编写plc程序过程中, 需要对plc中的数据进行访问,这就是寻址;直接寻址间接寻址;直接寻址直接寻址就是直接对数据的存储单元进行访问;根据表达方式的不同,可分为绝对寻址和符号寻址;对于plc中的标准数据存储区包括IQMTCL以及标准数据块,既可以使用绝对寻址,也可以使用符号寻址;绝对寻址在使用绝对寻址时,可以寻址的宽度包括位,字,节字,双字;

大小曲奇的博客 2129

你一直忽略的神器:离你最近的超强语音输入法(微信语音输入全攻略,支持全局混用)

你一直忽略的语音输入工具🎤 ,其实就在身边!无需额外软件,即可实现全局语音转文字⚡ 支持中英文混输,还能与其他输入法混合使用,聊天、办公都能高效完成,让你的输入效率轻松翻倍🚀

XiaoqiangClub的博客 961

Spring bean加载的三种方式

Spring bean加载的三种方式 UserService: package com.njtech.service; public interface UserService { public void add(); } UserServiceImpl: package com.njtech.service.Impl; import com.njtech.service.Use...

不怕万人阻挡,只怕自己投降 5697

20、自定义用户窗体:从创建到使用

本文详细介绍了在Excel VBA中创建和使用自定义用户窗体的完整过程,涵盖从窗体设计、控件添加与属性设置,到事件处理程序编写及宏调用的各个环节。通过实际示例讲解了如何实现文本大小写转换和员工信息录入等功能,并深入解析了常用控件的属性与事件机制。同时提供了控件命名规范、快捷键使用、布局技巧等实用建议,帮助读者构建高效、交互性强的VBA用户界面。

h0i1j2k3l的博客 137

Spring bean加载的顺序探究

在认识AnnotationConfigApplicationContext加载流程的时候,实际上涉及到了一些顺序BeanFactoryPostProcessor 是优先加载的,且有一系列顺序观察refresh()方法的,可以看到普通bean加载是有一定顺序的, 如下/***/if (!按照beanDefinitions顺序加载@Service@Override。

master-dragon的专栏 1185

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Spring的bean加载流程

spring的bean记载流程

qq_38645103的博客 5798

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Spring Bean加载优先级

@ConditionalOnMissingBean / @ConditionalOnBean 与 Bean 的加载优先级分析

铭记: 2096

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Spring Bean的加载方式【8种】

本文讲述了Spring bean 的八种加载方式,包含的内容足以应付大多数场景

阿杆的博客 4206

Spring源码十五:Bean的加载

Spring框架中Bean创建与获取的核心逻辑,实现了复杂的Bean生命周期管理。通过单例缓存、合并Bean定义、处理依赖关系以及类型转换等步骤,确保了Bean实例的正确创建与获取。此流程通过细致的检查与处理,避免了循环依赖,并支持多种作用域的Bean管理,为应用提供了灵活且可靠的Bean管理机制。

Jeremy程序员 2万+

Spring中Bean的加载过程

为后续 Bean 实例化做准备。

m0_64630668的博客 765

【Spring】Bean加载控制

很多时候我们需要根据不同的条件在容器中加载不同的Bean,或者根据不同的条件来选择是否在容器中加载某个Bean,这就是Bean的加载控制,一般我们可以通过编程式或注解式两种不同的方式来完成Bean的加载控制

qq_50675319的博客 1593

Spring Bean 加载顺序

上次听同事说过,同时看了几篇文章,整理一下 Spring Bean 加载顺序 { 1.start 2.@compoment( @Service, @Controller, @Config) 3.@import 4.@Bean } spring根据如上顺序递归去加载bean,例如A中 配置了 @Compoment B, spring就会先去加载B, 此时如果B中有C的Bean声明,又会...

tpwulawula的博客 2399

【Spring】Bean的八种加载方式

一、XML方式声明bean 配置文件 1.在xml中声明自定义的bean <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springfra

Hello World! 2426

Spring如何控制Bean的加载顺序

这里我简单介绍一个这个接口的用处, 等到整理到相关源码的时候再详细介绍。接口是在 Spring 容器刷新之前执行的一个回调函数。执行时机:Spring 内部执行方法前;SpringBoot 执行run()方法前。一般有什么用呢?在 SpringBoot 应用中 Classpath 上会有很多 jar 包,有些 jar 包需要在refresh()调用前对应用上下文做一些初始化动作,因此会提供接口的实现类,放在如下图的文件中,这样会被发现,然后完成对应初始化。

kfashfasf的博客 1044

spring bean加载原理

简单的分析了一下spring bean的加载原理,属于个人的理解,源码比这个要复杂的多: spring的配置文件applicationContext.xml的内容如下: beans> bean id="userDao" class="com.qjl.study.spring.dao.impl.UserDaoImpl">bean> beans> 非web环境下我们通常这么来

. 8863

Spring 中如何控制 Bean 的加载顺序?

当多个组件(如拦截器、过滤器、监听器等)需要按照特定的顺序执行时,

江南一点雨的专栏 1947

Spring源码系列:Bean的加载

Spring源码系列:Bean的加载前言一. Bean的加载 前言 在我们前面两章,我们讲完了Spring如何加载、解析资源文件以及如何将其转化为BeanDefinition的(标签的解析)流程。那么接下来我们来看下Bean的一个加载过程。我们来从这段代码为切入口: public static void main(String[] args) { ClassPathResource resource = new ClassPathResource("test.xml"); DefaultListable

Zong_0915的博客 2058
上一篇: Spring xml bean标签的解析,注册
下一篇: spring 整合mybatis源码分析
god_love_hlq_xff
博客等级 码龄11年 27粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值