spring注解驱动系列-- BeanPostProcessor与BeanFactoryPostProcessor

一、BeanPostProcessor与BeanFactoryPostProcessor的定义

一、BeanPostProcessor

bean后置处理器,bean创建对象初始化前后进行拦截工作的

二、BeanFactoryPostProcessor 

beanFactory的后置处理器,在BeanFactory标准初始化之后调用,来定制和修改BeanFactory的内容,所有的bean定义信息已经保存加载到beanFactory,但是bean的实例还未创建。BeanFactoryPostProcessor是BeanFactory的一个钩子接口

二、原理 

一、测试demo

@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("MyBeanFactoryPostProcessor...postProcessBeanFactory...");
        int count = beanFactory.getBeanDefinitionCount();
        String[] names = beanFactory.getBeanDefinitionNames();
        System.out.println("当前BeanFactory中有"+count+" 个Bean");
        System.out.println(Arrays.asList(names));
    }
}



@ComponentScan("com.spring.annotate.beans")
@Configuration
public class BeansFactoryConfig {
    @Bean
    public Blue blue(){
        return new Blue();
    }
}




    @Test
    void contextLoads() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(BeansFactoryConfig.class);
        applicationContext.close();
    }

结果:

二、原理

一、通过idea工具可以查看到spring源码接口,发现它还有一个子接口BeanDefinitionRegistryPostProcessor

二、BeanFactoryPostProcessor接口

@FunctionalInterface
public interface BeanFactoryPostProcessor {

    /**
     * Modify the application context's internal bean factory after its standard
     * initialization. All bean definitions will have been loaded, but no beans
     * will have been instantiated yet. This allows for overriding or adding
     * properties even to eager-initializing beans.
     * @param beanFactory the bean factory used by the application context
     * @throws org.springframework.beans.BeansException in case of errors
     */
    void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;

}

从源码上看,这个接口只有一个方法,也就是说spring是通过这个方法对BeanFactory进行增强的

三、BeanDefinitionRegistryPostProcessor接口

public interface BeanDefinitionRegistryPostProcessor extends BeanFactoryPostProcessor {

    /**
     * Modify the application context's internal bean definition registry after its
     * standard initialization. All regular bean definitions will have been loaded,
     * but no beans will have been instantiated yet. This allows for adding further
     * bean definitions before the next post-processing phase kicks in.
     * @param registry the bean definition registry used by the application context
     * @throws org.springframework.beans.BeansException in case of errors
     */
    void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException;

}
 

此接口也只有一个方法,是为了Bean的注册而生,BeanDefinitionRegistry 是BeanDefinition的注册器,而注册Bean的过程是将满足Bean条件的类解析为BeanDefinition对象然后注册到BeanDefinition注册器中。

总结:

BeanFactoryPostProcessor和BeanDefinitionRegistryPostProcessor都是扩展Bean的加载方式,当我们需要自定义自己的Bean加载方式时实现BeanDefinitionRegistryPostProcessor接口即可。@Configuration注解的实现就是基于BeanDefinitionRegistryPostProcessor接口完成

四、BeanFactoryPostProcessor 原理

首先我们需要清楚,AbstractApplicationContext类中refresh()是spring加载Bean的核心方法,大部分的处理逻辑都是在这个方法中完成。执行时机是:所有的bean定义已经保存加载到beanFactory,但是bean的实例还未创建

@Override
	public void refresh() throws BeansException, IllegalStateException {
		synchronized (this.startupShutdownMonitor) {
			StartupStep contextRefresh = this.applicationStartup.start("spring.context.refresh");

			// Prepare this context for refreshing.
			/**
			 * 准备上下文刷新工作,如设置初始值
			 */
			prepareRefresh();

			// Tell the subclass to refresh the internal bean factory.
			/**
			 * 告诉子类刷新内部beanFactory,返回Bean工厂
			 */
			ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();

			// Prepare the bean factory for use in this context.
			/**
			 * 准备beanFactory,以便于上下文中使用
			 */
			prepareBeanFactory(beanFactory);

			try {
				// Allows post-processing of the bean factory in context subclasses.
				/**
				 * 允许在上下文子类中对bean工厂进行后处理。
				 */
				postProcessBeanFactory(beanFactory);

				/**
				 * 开启处理PostProcessors步骤器
				 */
				StartupStep beanPostProcess = this.applicationStartup.start("spring.context.beans.post-process");
				// Invoke factory processors registered as beans in the context.
				/**
				 * 调用BeanFactory的后置处理器
				 */
				invokeBeanFactoryPostProcessors(beanFactory);

				// Register bean processors that intercept bean creation.
				/**
				 *
				 * 注册拦截bean创建的bean处理器
				 */
				registerBeanPostProcessors(beanFactory);
				/**
				 * 处理PostProcessors步骤器
				 */
				beanPostProcess.end();

				// Initialize message source for this context.
				/**
				 * 初始化MessageSource
				 */
				initMessageSource();

				// Initialize event multicaster for this context.
				/**
				 * 初始化Application监听器的管理Bean(ApplicationEventMulticaster)
				 */
				initApplicationEventMulticaster();

				// Initialize other special beans in specific context subclasses.
				/**
				 * 模板模式,刷新Bean的操作,由子类实现具体逻辑
				 */
				onRefresh();

				// Check for listener beans and register them.
				/**
				 * 检查和注册监听器
				 */
				registerListeners();

				// Instantiate all remaining (non-lazy-init) singletons.
				/**
				 * 实例化所有(非惰性初始化)单例
				 */
				finishBeanFactoryInitialization(beanFactory);

				// Last step: publish corresponding event.
				/**
				 * 发布相应的事件
				 */
				finishRefresh();
			}

			catch (BeansException ex) {
				if (logger.isWarnEnabled()) {
					logger.warn("Exception encountered during context initialization - " +
							"cancelling refresh attempt: " + ex);
				}

				// Destroy already created singletons to avoid dangling resources.
				destroyBeans();

				// Reset 'active' flag.
				cancelRefresh(ex);

				// Propagate exception to caller.
				throw ex;
			}

			finally {
				// Reset common introspection caches in Spring's core, since we
				// might not ever need metadata for singleton beans anymore...
				resetCommonCaches();
				contextRefresh.end();
			}
		}
	}

一、 ioc容器创建对象

二、invokeBeanFactoryPostProcessors(beanFactory);

	protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory) {
		/**
		 * 执行BeanFactoryPostProcessor,是该方法的处理核心
		 */
		PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors());

		// Detect a LoadTimeWeaver and prepare for weaving, if found in the meantime
		// (e.g. through an @Bean method registered by ConfigurationClassPostProcessor)
		/**
		 * 检查和赋初始值
		 */
		if (!NativeDetector.inNativeImage() && beanFactory.getTempClassLoader() == null && beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
			beanFactory.addBeanPostProcessor(new LoadTimeWeaverAwareProcessor(beanFactory));
			beanFactory.setTempClassLoader(new ContextTypeMatchClassLoader(beanFactory.getBeanClassLoader()));
		}
	}

  三、PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors())方法

public static void invokeBeanFactoryPostProcessors(
			ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) {
		Set<String> processedBeans = new HashSet<>();

		/**
		 * 首先调用BeanDefinitionRegistryPostProcessors(如果有)。
		 */
		if (beanFactory instanceof BeanDefinitionRegistry) {
			BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
			/**
			 * 用于存放BeanFactoryPostProcessor的对象
			 */
			List<BeanFactoryPostProcessor> regularPostProcessors = new ArrayList<>();
			/**
			 * 用户存放BeanDefinitionRegistryPostProcessor对象
			 */
			List<BeanDefinitionRegistryPostProcessor> registryProcessors = new ArrayList<>();


			/********************************* 下面处理BeanDefinitionRegistryPostProcessor逻辑 *************************************/


			/**
			 * 遍历最原始的BeanFactoryPostProcessor列表,找出BeanDefinitionRegistryPostProcessor和 BeanFactoryPostProcessor
			 * BeanDefinitionRegistryPostProcessor是BeanFactoryPostProcessor的子接口
			 */
			for (BeanFactoryPostProcessor postProcessor : beanFactoryPostProcessors) {
				if (postProcessor instanceof BeanDefinitionRegistryPostProcessor) {
					BeanDefinitionRegistryPostProcessor registryProcessor =
							(BeanDefinitionRegistryPostProcessor) postProcessor;
					/**
					 * 执行BeanDefinitionRegistryPostProcessor的postProcessBeanDefinitionRegistry
					 */
					registryProcessor.postProcessBeanDefinitionRegistry(registry);
					registryProcessors.add(registryProcessor);
				}
				else {
					regularPostProcessors.add(postProcessor);
				}
			}

			/**
			 * 定义当前找到的BeanDefinitionRegistryPostProcessor临时存储
			 */
			List<BeanDefinitionRegistryPostProcessor> currentRegistryProcessors = new ArrayList<>();

			// First, invoke the BeanDefinitionRegistryPostProcessors that implement PriorityOrdered.
			// 首先,调用实现PriorityOrdered的BeanDefinitionRegistryPostProcessor。
			String[] postProcessorNames =
					beanFactory.getBeanNamesForType(BeanDefinitionRegistryPostProcessor.class, true, false);
			for (String ppName : postProcessorNames) {
				if (beanFactory.isTypeMatch(ppName, PriorityOrdered.class)) {
					currentRegistryProcessors.add(beanFactory.getBean(ppName, BeanDefinitionRegistryPostProcessor.class));
					processedBeans.add(ppName);
				}
			}
			sortPostProcessors(currentRegistryProcessors, beanFactory);
			registryProcessors.addAll(currentRegistryProcessors);
			invokeBeanDefinitionRegistryPostProcessors(currentRegistryProcessors, registry, beanFactory.getApplicationStartup());
			currentRegistryProcessors.clear();

			// 接下来,调用实现Ordered的BeanDefinitionRegistryPostProcessor。
			postProcessorNames = beanFactory.getBeanNamesForType(BeanDefinitionRegistryPostProcessor.class, true, false);
			for (String ppName : postProcessorNames) {
				if (!processedBeans.contains(ppName) && beanFactory.isTypeMatch(ppName, Ordered.class)) {
					currentRegistryProcessors.add(beanFactory.getBean(ppName, BeanDefinitionRegistryPostProcessor.class));
					processedBeans.add(ppName);
				}
			}
			sortPostProcessors(currentRegistryProcessors, beanFactory);
			registryProcessors.addAll(currentRegistryProcessors);
			invokeBeanDefinitionRegistryPostProcessors(currentRegistryProcessors, registry, beanFactory.getApplicationStartup());
			currentRegistryProcessors.clear();

			// 最后,调用所有其他BeanDefinitionRegistryPostProcessor,直到不再出现其他BeanDefinitionRegistryPostProcessor。
			boolean reiterate = true;
			while (reiterate) {
				reiterate = false;
				postProcessorNames = beanFactory.getBeanNamesForType(BeanDefinitionRegistryPostProcessor.class, true, false);
				for (String ppName : postProcessorNames) {
					if (!processedBeans.contains(ppName)) {
						currentRegistryProcessors.add(beanFactory.getBean(ppName, BeanDefinitionRegistryPostProcessor.class));
						processedBeans.add(ppName);
						reiterate = true;
					}
				}
				sortPostProcessors(currentRegistryProcessors, beanFactory);
				registryProcessors.addAll(currentRegistryProcessors);
				invokeBeanDefinitionRegistryPostProcessors(currentRegistryProcessors, registry, beanFactory.getApplicationStartup());
				currentRegistryProcessors.clear();
			}

			/**
			 * 批量执行BeanDefinitionRegistryPostProcessor的postProcessBeanDefinitionRegistry
			 */
			invokeBeanFactoryPostProcessors(registryProcessors, beanFactory);
			/**
			 * 批量执行BeanFactoryPostProcessor(最开始的BeanFactoryPostProcessor)
			 */
			invokeBeanFactoryPostProcessors(regularPostProcessors, beanFactory);
		}

		else {
			// Invoke factory processors registered with the context instance.
			invokeBeanFactoryPostProcessors(beanFactoryPostProcessors, beanFactory);
		}

		/********************************* 下面处理BeanFactoryPostProcessor逻辑(可能执行上面步骤产生新的BeanFactoryPostProcessor),执行逻辑和BeanDefinitionRegistryPostProcessor一致 *************************************/

		// Do not initialize FactoryBeans here: We need to leave all regular beans
		// uninitialized to let the bean factory post-processors apply to them!
		String[] postProcessorNames =
				beanFactory.getBeanNamesForType(BeanFactoryPostProcessor.class, true, false);

		// Separate between BeanFactoryPostProcessors that implement PriorityOrdered,
		// Ordered, and the rest.
		List<BeanFactoryPostProcessor> priorityOrderedPostProcessors = new ArrayList<>();
		List<String> orderedPostProcessorNames = new ArrayList<>();
		List<String> nonOrderedPostProcessorNames = new ArrayList<>();
		for (String ppName : postProcessorNames) {
			if (processedBeans.contains(ppName)) {
				// skip - already processed in first phase above
			}
			else if (beanFactory.isTypeMatch(ppName, PriorityOrdered.class)) {
				priorityOrderedPostProcessors.add(beanFactory.getBean(ppName, BeanFactoryPostProcessor.class));
			}
			else if (beanFactory.isTypeMatch(ppName, Ordered.class)) {
				orderedPostProcessorNames.add(ppName);
			}
			else {
				nonOrderedPostProcessorNames.add(ppName);
			}
		}

		// First, invoke the BeanFactoryPostProcessors that implement PriorityOrdered.
		sortPostProcessors(priorityOrderedPostProcessors, beanFactory);
		invokeBeanFactoryPostProcessors(priorityOrderedPostProcessors, beanFactory);

		// Next, invoke the BeanFactoryPostProcessors that implement Ordered.
		List<BeanFactoryPostProcessor> orderedPostProcessors = new ArrayList<>(orderedPostProcessorNames.size());
		for (String postProcessorName : orderedPostProcessorNames) {
			orderedPostProcessors.add(beanFactory.getBean(postProcessorName, BeanFactoryPostProcessor.class));
		}
		sortPostProcessors(orderedPostProcessors, beanFactory);
		invokeBeanFactoryPostProcessors(orderedPostProcessors, beanFactory);

		// Finally, invoke all other BeanFactoryPostProcessors.
		List<BeanFactoryPostProcessor> nonOrderedPostProcessors = new ArrayList<>(nonOrderedPostProcessorNames.size());
		for (String postProcessorName : nonOrderedPostProcessorNames) {
			nonOrderedPostProcessors.add(beanFactory.getBean(postProcessorName, BeanFactoryPostProcessor.class));
		}
		invokeBeanFactoryPostProcessors(nonOrderedPostProcessors, beanFactory);

		// Clear cached merged bean definitions since the post-processors might have
		// modified the original metadata, e.g. replacing placeholders in values...
		beanFactory.clearMetadataCache();
	}


	/**
	 * 排序BeanFactoryPostProcessor
	 * @param postProcessors
	 * @param beanFactory
	 */
	private static void sortPostProcessors(List<?> postProcessors, ConfigurableListableBeanFactory beanFactory) {
		// Nothing to sort?
		if (postProcessors.size() <= 1) {
			return;
		}
		Comparator<Object> comparatorToUse = null;
		if (beanFactory instanceof DefaultListableBeanFactory) {
			comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator();
		}
		if (comparatorToUse == null) {
			comparatorToUse = OrderComparator.INSTANCE;
		}
		postProcessors.sort(comparatorToUse);
	}


	/**
	 * 执行  BeanDefinitionRegistryPostProcessor
	 * @param postProcessors
	 * @param registry
	 * @param applicationStartup
	 */
	private static void invokeBeanDefinitionRegistryPostProcessors(
			Collection<? extends BeanDefinitionRegistryPostProcessor> postProcessors, BeanDefinitionRegistry registry, ApplicationStartup applicationStartup) {

		for (BeanDefinitionRegistryPostProcessor postProcessor : postProcessors) {
			StartupStep postProcessBeanDefRegistry = applicationStartup.start("spring.context.beandef-registry.post-process")
					.tag("postProcessor", postProcessor::toString);
			postProcessor.postProcessBeanDefinitionRegistry(registry);
			postProcessBeanDefRegistry.end();
		}
	}


	/**
	 * 执行invokeBeanFactoryPostProcessors
	 * @param postProcessors
	 * @param beanFactory
	 */
	private static void invokeBeanFactoryPostProcessors(
			Collection<? extends BeanFactoryPostProcessor> postProcessors, ConfigurableListableBeanFactory beanFactory) {

		for (BeanFactoryPostProcessor postProcessor : postProcessors) {
			StartupStep postProcessBeanFactory = beanFactory.getApplicationStartup().start("spring.context.bean-factory.post-process")
					.tag("postProcessor", postProcessor::toString);
			postProcessor.postProcessBeanFactory(beanFactory);
			postProcessBeanFactory.end();
		}
	}

	

一、遍历最原始的BeanFactoryPostProcessor,找到BeanDefinitionRegistryPostProcessor和BeanFactoryPostProcessor,且执行BeanDefinitionRegistryPostProcessor的postProcessBeanDefinitionRegistry(registry)方法加载Bean。

二、从BeanFactory中寻找BeanDefinitionRegistryPostProcessorPriorityOrdered(最高优先级的排序)类型Bean,排序后执行postProcessBeanDefinitionRegistry(registry)方法加载Bean。

三、从BeanFactory中寻找BeanDefinitionRegistryPostProcessor未被加载的Ordered(排序)类型Bean,排序后执行postProcessBeanDefinitionRegistry(registry)方法加载Bean。

四、从BeanFactory中寻找出未被加载的BeanDefinitionRegistryPostProcessor类型Bean,然后执行postProcessBeanDefinitionRegistry(registry)方法加载Bean,这一步目的就是处理加载新的BeanDefinitionRegistryPostProcessor的Bean。

五、从BeanFactory中寻找BeanFactoryPostProcessorPriorityOrdered(最高优先级的排序)类型Bean,排序后执行postProcessBeanFactory(beanFactory)方法加载Bean。

六、从BeanFactory中寻找BeanFactoryPostProcessor未被加载的Ordered(排序)的类型Bean,排序后执行postProcessBeanFactory(beanFactory)方法加载Bean。

七、从BeanFactory中寻找出未排序BeanFactoryPostProcessor类型Bean,然后执行postProcessBeanFactory(beanFactory)方法加载Bean。

  • priorityOrderedPostProcessors:放置有优先级排序的接口
  • orderedPostProcessorNames:放置有排序的PostProcessorNames
  • nonOrderedPostProcessorNames:放置普通的PostProcessorNames

五、BeanDefinitionRegistryPostProcessor原理

执行时机:在所有bean定义信息将要被加载,bean实例还未创建的,这个是将要被加载,BeanFactoryPostProcessor 这个是已经被加载,所以BeanDefinitionRegistryPostProcessor是在更前执行

1、BeanDefinition:容器中的每一个bean都会有一个对应的BeanDefinition实例,该实例负责保存bean对象的所有必要信息,包括bean对象的class类型、是否是抽象类、构造方法和参数、其它属性等等。

2、BeanDefinitionRegistry:

BeanDefinition是定义bean的,BeanDefinitionRegistry则是bean定义信息的保存中心,也叫注册中心,保存了bean的所有定义,以后BeanFactory就是按照BeanDefinitionRegistry里面保存的每一个bean定义信息创建bean实例。bean是单例还是多例,bean的类型,bean的ID等信息,都是存在BeanDefinitionRegistry里面。

3、BeanDefinitionRegistryPostProcessor:它是Spring框架的一个扩展点,用于对Bean定义的注册过程进行干预和定制。继承BeanFactoryPostProcessor接口,并在其基础上扩展了一个新的方法,即:postProcessBeanDefinitionRegistry()方法。

        用途:在Spring容器初始化时,首先会读取应用程序中的配置文件,并解析出所有的Bean定义,然后将这些Bean定义注册到容器中。在这个过程中,BeanDefinitionRegistryProcessor提供了一种机制,允许开发人员在Bean定义注册之前和之后对Bean定义进行自定义处理,例如添加,修改或删除Bean定义等。
        方法详解:

postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry):该方法在所有Bean定义加载完成之后,Bean实例化之前被调用,允许开发人员对Bean定义进行自定义修改,例如添加,修改或删除Bean定义等。
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory): 该方法是继承自BeanFactoryPostProcessor接口的方法,用于在BeanFactory完成实例化之后对BeanFactory进行后置处理。

一、ioc容器创建

二、调用refresh()方法,执行到里面的invokeBeanFactoryPostProcessors(beanFactory);方法

进入PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors());

 三、从容器中获取到所有的BeanDefinitionRegistryPostProcessor组件

	private static void invokeBeanDefinitionRegistryPostProcessors(
			Collection<? extends BeanDefinitionRegistryPostProcessor> postProcessors, BeanDefinitionRegistry registry) {

		for (BeanDefinitionRegistryPostProcessor postProcessor : postProcessors) {
			postProcessor.postProcessBeanDefinitionRegistry(registry);
		}
	}

1、依次触发所有的postProcessBeanDefinitionRegistry()方法

2、再来触发postProcessBeanFactory()方法,是BeanFactoryPostProcessor里面的方法。 

四、最后到BeanFactoryPostProcessor组件时还会依次触发postProcessBeanFactory()方法 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/563286.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

服务器Linux上杀死特定进程的命令:kill

1、查看用户XXX正在运行的进程 top -u xxx2、查看想要杀死的进程对应的PID 先找到此进程对应的命令 取其中的main-a3c.py即可 ps -aux | grep main-a3c.py可以看到对应的PID是1325390使用kill杀死对应PID的进程 kill -9 1325390成功&#xff0c;gpustat可以看到之前一直占…

JVM虚拟机(十二)ParallelGC、CMS、G1垃圾收集器的 GC 日志解析

目录 一、如何开启 GC 日志&#xff1f;二、GC 日志分析2.1 PSPO 日志分析2.2 ParNewCMS 日志分析2.3 G1 日志分析 三、GC 发生的原因3.1 Allocation Failure&#xff1a;新生代空间不足&#xff0c;触发 Minor GC3.2 Metadata GC Threshold&#xff1a;元数据&#xff08;方法…

Microchip 32位MCU CAN驱动图文教程-附源码

文章目录 创建一个新的32位MCU工程Microchip MCC Harmony配置界面说明在MCC下配置系统的时钟在MCC下配置所需要使用的模块配置调试打印模块配置CAN模块配置管脚功能修改系统堆栈大小生成代码 添加用户代码 创建一个新的32位MCU工程 确保电脑上已经安装最新的MPlab X IDE、XC32编…

【Qt】探索Qt框架:跨平台GUI开发的利器

文章目录 1. Qt框架概述1.1. Qt框架的优点1.2. Qt框架支持的系统1.3. Qt开发环境 2. 搭建 Qt 开发环境2.1. Qt SDK 的下载和安装2.2. 新建项目: 3. Qt 框架内容简介总结 在当今软件开发领域&#xff0c;跨平台性和用户界面的友好性是至关重要的。而Qt框架作为一款跨平台的C图形…

西安大秦软件

西安大秦软件 大秦软件 想做小程序、APP、Web 系统&#xff0c;请找我&#xff0c;包您满意&#xff01; 刘大强 &#xff08;销售经理&#xff09; 电话&#xff1a;198 8892 6712 微信&#xff1a;198 8892 6712 欢迎咨询 西安大秦时代网络科技有限公司

认知觉醒 PDF电子版 下载

认知觉醒 PDF电子版 开启自我改变的原动力 周岭 / 人民邮电出版社 / 2020-10 链接&#xff1a;https://pan.baidu.com/s/1EHUK_AhvE5TWAZsYXFQ5QA?pwdwrho 提取码&#xff1a;wrho

面试后,公司如何决定你的去留

在现代职场中&#xff0c;求职者在经历了一系列严格的面试流程后&#xff0c;往往会进入一段等待期。在这段时间里&#xff0c;他们满怀希望地等待企业的最终反馈。但有一个现象普遍存在&#xff1a;无论面试过程如何&#xff0c;最终决定权总是掌握在公司手中&#xff0c;由公…

【Python性能优化】list、array与set

list、array与set 详述测试代码 详述 本文对比 list 与 set 在插入和取值时的性能差异&#xff0c;以提供一条什么时候该选择什么数据类型的建议。先上结果&#xff1a; array 与 list 的不同&#xff1a; 内存方面 array 是 C array 的包装&#xff0c;它直接存储数据&#xf…

Llama 3大模型发布!快速体验推理及微调

Meta&#xff0c;一家全球知名的科技和社交媒体巨头&#xff0c;在其官方网站上正式宣布了一款开源的大型预训练语言模型——Llama-3。 据了解&#xff0c;Llama-3模型提供了两种不同参数规模的版本&#xff0c;分别是80亿参数和700亿参数。这两种版本分别针对基础的预训练任务…

JVM-垃圾收集算法

前言 在 Java 中&#xff0c;垃圾收集&#xff08;Garbage Collection&#xff09;是一种自动管理内存的机制&#xff0c;它负责在运行时识别和释放不再被程序使用的内存&#xff0c;从而避免内存泄漏和悬空引用问题。本篇文章将介绍三种常见的垃圾收集算法。 标记-清除&…

OCT2Former: A retinal OCT-angiography vessel segmentationtransformer论文总结

论文(COMPUT METH PROG BIO)&#xff1a;OCT2Former: A retinal OCT-angiography vessel segmentation transformer 源码&#xff1a;https://github.com/coreeey/OCT2Former 一、摘要 背景与目的&#xff1a;视网膜血管分割在视网膜疾病自动筛查与诊断中起着重要作用。如何分…

2024 抖音欢笑中国年(五):Wasm、WebGL 在互动技术中的创新应用

前言 随着 Web 前端技术的不断发展&#xff0c;越来越多的新兴技术方案被引入到 Web 开发中&#xff0c;其中 Wasm 和 WebGL 作为前端领域的两大利器&#xff0c;为开发者带来了更多的可能性。 本文将结合2024 年抖音欢笑中国年的部分项目&#xff0c;重点介绍如何利用 Wasm 和…

TCP 协议特性

1. TCP 基本认识 TCP 是面向连接的、可靠的、基于字节流的传输层通信协议。 面向连接&#xff1a;一定是「一对一」才能连接&#xff0c;不能像 UDP 协议可以一个主机同时向多个主机发送消息&#xff0c;也就是一对多是无法做到的&#xff1b; 可靠的&#xff1a;无论的网络链…

【批量区域识别内容重命名】批量识别图片区域文字并重命名,批量图片部分识别内容重命文件,PDF区域识别提取重命名

我们在工作和生活中经常遇到这样的需求&#xff1a;比如将以下的图片区域识别进行重命名&#xff0c;批量识别后改成以时间和工作内容重命名&#xff0c;便于日后检索&#xff0c;快速查询 首先我们拍摄照片用到的是水印相机&#xff0c;这里的文字呢我们需要加个背景&#xff…

C++模版初阶----函数模版、类模版

C模版初阶 1. 泛型编程2. 函数模板2.1 函数模板概念2.2函数模板格式2.3 函数模板的原理2.4 函数模板的实例化2.5 函数模版的匹配原则 3. 类模板3.1 类模板的定义格式3.2 类模板的实例化 总结 1. 泛型编程 泛型编程 : 编写与类型无关的通用代码&#xff0c;是代码复用的一种手段…

利用STM32 HAL库实现USART串口通信,并通过printf重定向输出“Hello World“

一、开发环境 硬件&#xff1a;正点原子探索者 V3 STM32F407 开发板 单片机&#xff1a;STM32F407ZGT6 Keil版本&#xff1a;5.32 STM32CubeMX版本&#xff1a;6.9.2 STM32Cube MCU Packges版本&#xff1a;STM32F4 V1.27.1 上一篇使用STM32F407的HAL库只需1行代码实现US…

#STM32F407VET6(天空星)标准库和HAL驱动ILI9341

一、驱动方式&#xff1a;软件SPI&#xff0c;屏幕像素320*240 二、标准库含触摸&#xff0c;HAL库不含触摸 三、立创参考的文档 【立创天空星ST32F407VET6】模块移植手册 - 飞书云文档 (feishu.cn)https://lceda001.feishu.cn/wiki/MFNpw4STVi5ImikkcH1clWrlnqb 四、引脚分…

HIVE无法启动问题

​ 启动不了hive 一直在加载中&#xff01; 问题&#xff1a;当我们打开电脑 想要学习hive时 我们却发现 它一直卡在启动页面 true一直后没有信息或者报错 原因&#xff1a;我们在之前学习时 在配置hdfs的高可用时&#xff08;High Availability 简称HA&#xff09; 高可用…

2024第十五届蓝桥杯省赛C++A组程序设计题解

ps&#xff1a;没有答案&#xff0c;考场上的代码&#xff0c;不一定对&#xff0c;大佬们轻喷&#xff0c;可以提供点更好的思路~ 试题C&#xff1a;训练士兵 解题思路 对于每次训练&#xff0c;需要考虑采用士兵单独训练还是组团训练的方式&#xff0c;故每次训练将所需训练…

【网站项目】“最多跑一次”小程序

&#x1f64a;作者简介&#xff1a;拥有多年开发工作经验&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的项目或者毕业设计。 代码可以私聊博主获取。&#x1f339;赠送计算机毕业设计600个选题excel文件&#xff0c;帮助大学选题。赠送开题报告模板&#xff…