当前位置: 首页 > news >正文

SpringBoot 源码分析初始化应用上下文(1)-createApplicationContext

前言:springBoot的版本是  2.2.4.RELEASE

一、入口

/*** Run the Spring application, creating and refreshing a new* {@link ApplicationContext}.* @param args the application arguments (usually passed from a Java main method)* @return a running {@link ApplicationContext}*/public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch = new StopWatch();stopWatch.start();ConfigurableApplicationContext context = null;Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();configureHeadlessProperty();SpringApplicationRunListeners listeners = getRunListeners(args);listeners.starting();try {ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);configureIgnoreBeanInfo(environment);Banner printedBanner = printBanner(environment);//主要看这个方法,初始化应用上下文context = createApplicationContext();exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class,new Class[] { ConfigurableApplicationContext.class }, context);prepareContext(context, environment, listeners, applicationArguments, printedBanner);refreshContext(context);afterRefresh(context, applicationArguments);stopWatch.stop();if (this.logStartupInfo) {new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);}listeners.started(context);callRunners(context, applicationArguments);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, listeners);throw new IllegalStateException(ex);}try {listeners.running(context);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, null);throw new IllegalStateException(ex);}return context;}

问题切入:为什么叫做上下文对象呢?上下文对象,就是当前应用环境下的一个集合

初始化(创建)上下文对象主要看上面注释那行,即:

context = createApplicationContext();

接着看下 createApplicationContext() 这个方法的实现

截图:

代码:

/*** Strategy method used to create the {@link ApplicationContext}. By default this* method will respect any explicitly set application context or application context* class before falling back to a suitable default.* @return the application context (not yet refreshed)* @see #setApplicationContextClass(Class)*/protected ConfigurableApplicationContext createApplicationContext() {Class<?> contextClass = this.applicationContextClass;if (contextClass == null) {try {switch (this.webApplicationType) {case SERVLET:// 创建上下文对象 AnnotationConfigServletWebServerApplicationContext 进行实例化的过程中,此时 ioc 容器也会被创建contextClass = Class.forName(DEFAULT_SERVLET_WEB_CONTEXT_CLASS);break;case REACTIVE:contextClass = Class.forName(DEFAULT_REACTIVE_WEB_CONTEXT_CLASS);break;default:contextClass = Class.forName(DEFAULT_CONTEXT_CLASS);}}catch (ClassNotFoundException ex) {throw new IllegalStateException("Unable create a default ApplicationContext, please specify an ApplicationContextClass", ex);}}//创建 AnnotationConfigServletWebServerApplicationContext 对象的无参构造return (ConfigurableApplicationContext) BeanUtils.instantiateClass(contextClass);}

 接着看下AnnotationConfigServletWebServerApplicationContext 这个对象的继承关系

 从继承关系上面看继承关系比较深,同时可以看到 GenericApplicationContext(通用上下文对象),上面实例化AnnotationConfigServletWebServerApplicationContext的时候就是从该对象的无参构造方法开始的,我们就从AnnotationConfigServletWebServerApplicationContext对象的无参构造方法从代码上面看一下代码逻辑,注意:子类实例化的时候先实例化父类的构造方法

截图如下:

 1、AnnotationConfigServletWebServerApplicationContext 的无参构造【注解配置Servlet Web服务器应用程序上下文】

2、ServletWebServerApplicationContext 的无参构造【Servlet Web服务器应用程序上下文】

==> 这一步啥事没做

 3、GenericWebApplicationContext 的无参构造【通用Web应用程序上下文】

==> 这个方法实例化的时候继承了父类

 4、GenericApplicationContext 的无参构造【通用应用程序上下文】

 ==> 这里直接new一个 DefaultListableBeanFactory 对象,这个对象就是IOC容器最开始的样子,

这里其实是已经创建了 bean 工厂, DefaultListableBeanFactory 这个类里面有一个beanDefinitionMap,就是用来存放bean对象的。

二、AnnotationConfigServletWebServerApplicationContext 无参构造的两个重要方法

截图:

代码:

/*** Create a new {@link AnnotationConfigServletWebServerApplicationContext} that needs* to be populated through {@link #register} calls and then manually* {@linkplain #refresh refreshed}.*/public AnnotationConfigServletWebServerApplicationContext() {//创建一个读取注解的Bean定义读取器//什么是 Bean 定义?BeanDefinition 完成了 spring 内部 Bean 的 BeanDefinition 的注册(主要是后置处理器)this.reader = new AnnotatedBeanDefinitionReader(this);//创建 BeanDefinition 扫描器,可以用来扫描包或者类,继而转换为 bd,//spring 默认的扫描器其实不是这个 scanner 对象,而是在后面自己又重新 new 了一个 ClassPathBeanDefinitionScanner //spring 在执行工程后置器 ConfigurationClassPostProcessor 时,去扫描包时会 new//这里 scanner 仅仅是为了 程序员可以手动调用 AnnotationConfigApplicationContext 对象的 scanner方法this.scanner = new ClassPathBeanDefinitionScanner(this);}

2.1 AnnotatedBeanDefinitionReader 构造方法

在看这个方法之前,我们先打个断点,然后看下this里面的 beanDefinitionMap 里面是否有有值,即IOC容器中是否有bean对象,可以看到,到这一步还是没有值的,即还没有bean实例存在IOC容器中。接着我们继续跑下一步

到这一步的时候可以看到  beanDefinitionMap 已经有bean存进去了,接下来我们重点看下

AnnotatedBeanDefinitionReader 构造方法 都做了哪些事情。

 AnnotatedBeanDefinitionReader 构造方法

截图:

接着看其有参构造方法

截图:

代码:

/*** Create a new {@code AnnotatedBeanDefinitionReader} for the given registry,* using the given {@link Environment}.* @param registry the {@code BeanFactory} to load bean definitions into,* in the form of a {@code BeanDefinitionRegistry}* @param environment the {@code Environment} to use when evaluating bean definition* profiles.* @since 3.1*/public AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry, Environment environment) {Assert.notNull(registry, "BeanDefinitionRegistry must not be null");Assert.notNull(environment, "Environment must not be null");this.registry = registry;this.conditionEvaluator = new ConditionEvaluator(registry, environment, null);//根据名字顾名思义就是注册注解配置的处理器//也就是这个方法里面会注册一些用于处理注解的处理器AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry);}

 接着看 registerAnnotationConfigProcessors 这个方法

继续看 registerAnnotationConfigProcessors 方法

截图:

代码:

	/*** Register all relevant annotation post processors in the given registry.* @param registry the registry to operate on* @param source the configuration source element (already extracted)* that this registration was triggered from. May be {@code null}.* @return a Set of BeanDefinitionHolders, containing all bean definitions* that have actually been registered by this call*/public static Set<BeanDefinitionHolder> registerAnnotationConfigProcessors(BeanDefinitionRegistry registry, @Nullable Object source) {//unwrap 打开...的包装,这里即获取默认bean工厂对象DefaultListableBeanFactory beanFactory = unwrapDefaultListableBeanFactory(registry);if (beanFactory != null) {if (!(beanFactory.getDependencyComparator() instanceof AnnotationAwareOrderComparator)) {//主要解析 @Order 和 @Priority	beanFactory.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);}if (!(beanFactory.getAutowireCandidateResolver() instanceof ContextAnnotationAutowireCandidateResolver)) {//提供处理延迟加载的功能beanFactory.setAutowireCandidateResolver(new ContextAnnotationAutowireCandidateResolver());}}Set<BeanDefinitionHolder> beanDefs = new LinkedHashSet<>(8);//spring 默认 BeanDefinition 的注册if (!registry.containsBeanDefinition(CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME)) {RootBeanDefinition def = new RootBeanDefinition(ConfigurationClassPostProcessor.class);def.setSource(source);beanDefs.add(registerPostProcessor(registry, def, CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME));}//注册 AutowiredAnnotationBeanPostProcessorif (!registry.containsBeanDefinition(AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)) {RootBeanDefinition def = new RootBeanDefinition(AutowiredAnnotationBeanPostProcessor.class);def.setSource(source);beanDefs.add(registerPostProcessor(registry, def, AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME));}//注册 CommonAnnotationBeanPostProcessor// Check for JSR-250 support, and if present add the CommonAnnotationBeanPostProcessor.if (jsr250Present && !registry.containsBeanDefinition(COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)) {RootBeanDefinition def = new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class);def.setSource(source);beanDefs.add(registerPostProcessor(registry, def, COMMON_ANNOTATION_PROCESSOR_BEAN_NAME));}// Check for JPA support, and if present add the PersistenceAnnotationBeanPostProcessor.if (jpaPresent && !registry.containsBeanDefinition(PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME)) {RootBeanDefinition def = new RootBeanDefinition();try {def.setBeanClass(ClassUtils.forName(PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME,AnnotationConfigUtils.class.getClassLoader()));}catch (ClassNotFoundException ex) {throw new IllegalStateException("Cannot load optional framework class: " + PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME, ex);}def.setSource(source);beanDefs.add(registerPostProcessor(registry, def, PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME));}if (!registry.containsBeanDefinition(EVENT_LISTENER_PROCESSOR_BEAN_NAME)) {RootBeanDefinition def = new RootBeanDefinition(EventListenerMethodProcessor.class);def.setSource(source);beanDefs.add(registerPostProcessor(registry, def, EVENT_LISTENER_PROCESSOR_BEAN_NAME));}if (!registry.containsBeanDefinition(EVENT_LISTENER_FACTORY_BEAN_NAME)) {RootBeanDefinition def = new RootBeanDefinition(DefaultEventListenerFactory.class);def.setSource(source);beanDefs.add(registerPostProcessor(registry, def, EVENT_LISTENER_FACTORY_BEAN_NAME));}return beanDefs;}

 ==> 这里其实就是6个默认的spring内部bean的注册

(1) ConfigurationClassPostProcessor 配置类后置处理器

工厂后置处理器,这个后置处理器非常重要,基本上类上面的注解都在这里面判断并解析,spring的包扫描也在里面完成

 (2)  AutowiredAnnotationBeanPostProcessor 自动导入注解Bean后处置理器

主要是@Autowired,是一个bean的后置处理器,在bean的属性注入的时候会用到

(3)  CommonAnnotationBeanPostProcessor 通用注释Bean后置处理器

处理一些公共注解的,它是一个bean的后置处理器,可以处理@PostConstruct和@PreDestroy还有@Resource等

(4) PersistenceAnnotationBeanPostProcessor 持久性注释Bean后置处理器

对jpa的处理,所以需要引入spring-orm的包,没有引入的话则spring不会注册这个类

(5) internalEventListenerProcessor 内部事件监听器处理器

对 @EventListener 注解的处理,spring实现事件监听的方式有很多种,其中一种就是在方法上添加 @EventListener 注解

(6)  internalEventListenerFactory 内部事件监听器工厂

跟事件监听有关

接着我们看其中一个方法,挑第一个来跟一下逻辑代码

截图:

 接着看 registerPostProcessor 这个方法

截图:

 代码:

private static BeanDefinitionHolder registerPostProcessor(BeanDefinitionRegistry registry, RootBeanDefinition definition, String beanName) {definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);//registry 就是 AnnotationApplicationContext//这里是调用父类 GenericApplicationContext 中的 registerBeanDefinition 方法//调用 beanFactory 将 spring 默认的 BeanDefinition 注册进去registry.registerBeanDefinition(beanName, definition);//一开始就初始化了 DefaultListableBeanFactoryreturn new BeanDefinitionHolder(definition, beanName);}

接着看  registerBeanDefinition 方法

截图:

代码:

/*** Register a new bean definition with this registry.//在此注册表中注册一个新的bean定义,* Must support RootBeanDefinition and ChildBeanDefinition.//必须支持 RootBeanDefinition 和 ChildBeanDefinition* @param beanName the name of the bean instance to register //beanName 要注册的bean实例的名称* @param beanDefinition definition of the bean instance to register //beanDefinition  要注册的 bean 实例的定义* @throws BeanDefinitionStoreException if the BeanDefinition is invalid* @throws BeanDefinitionOverrideException if there is already a BeanDefinition* for the specified bean name and we are not allowed to override it //指定bean的名称,我们不允许覆盖它* @see GenericBeanDefinition* @see RootBeanDefinition* @see ChildBeanDefinition*/void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)throws BeanDefinitionStoreException;

这是一个接口,继续看其具体实现类 

这里看默认的工厂实现类 DefaultListableBeanFactory

截图:

代码:

//---------------------------------------------------------------------// Implementation of BeanDefinitionRegistry interface//---------------------------------------------------------------------@Overridepublic void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)throws BeanDefinitionStoreException {Assert.hasText(beanName, "Bean name must not be empty");Assert.notNull(beanDefinition, "BeanDefinition must not be null");if (beanDefinition instanceof AbstractBeanDefinition) {try {((AbstractBeanDefinition) beanDefinition).validate();}catch (BeanDefinitionValidationException ex) {throw new BeanDefinitionStoreException(beanDefinition.getResourceDescription(), beanName,"Validation of bean definition failed", ex);}}//在注册 bd 的时候判断该名字有没有被注册BeanDefinition existingDefinition = this.beanDefinitionMap.get(beanName);//该名字已经被注册//spring 默认支持覆盖 bd,但是 spring 会输入一些日志//1、两个 bd 相同的情况下//2、两个 bd 不同的情况 role 不同//3、两个 bd 不相同但是 role 相同if (existingDefinition != null) {if (!isAllowBeanDefinitionOverriding()) {throw new BeanDefinitionOverrideException(beanName, beanDefinition, existingDefinition);}//优先级else if (existingDefinition.getRole() < beanDefinition.getRole()) {// e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTUREif (logger.isInfoEnabled()) {logger.info("Overriding user-defined bean definition for bean '" + beanName +"' with a framework-generated bean definition: replacing [" +existingDefinition + "] with [" + beanDefinition + "]");}}else if (!beanDefinition.equals(existingDefinition)) {if (logger.isDebugEnabled()) {logger.debug("Overriding bean definition for bean '" + beanName +"' with a different definition: replacing [" + existingDefinition +"] with [" + beanDefinition + "]");}}else {if (logger.isTraceEnabled()) {logger.trace("Overriding bean definition for bean '" + beanName +"' with an equivalent definition: replacing [" + existingDefinition +"] with [" + beanDefinition + "]");}}this.beanDefinitionMap.put(beanName, beanDefinition);}else {//判断我们的 spring 容器是否开启实例化 bean了//如果为null,set 为空,没有开始就创建 bean 不会进入 ifif (hasBeanCreationStarted()) {// Cannot modify startup-time collection elements anymore (for stable iteration)synchronized (this.beanDefinitionMap) {//一个 map 一个 list ,list里面方法的 map 的 key,也就是 beanNamethis.beanDefinitionMap.put(beanName, beanDefinition);List<String> updatedDefinitions = new ArrayList<>(this.beanDefinitionNames.size() + 1);updatedDefinitions.addAll(this.beanDefinitionNames);updatedDefinitions.add(beanName);this.beanDefinitionNames = updatedDefinitions;//如果注册了 beanDefinition 的名字和手工注册的 bd 集合当中某个相同则删除手动注册的 beanNameremoveManualSingletonName(beanName);}}else {// Still in startup registration phasethis.beanDefinitionMap.put(beanName, beanDefinition);this.beanDefinitionNames.add(beanName);removeManualSingletonName(beanName);}this.frozenBeanDefinitionNames = null;}//判断注册的 bd 以及 beanName 是否存在if (existingDefinition != null || containsSingleton(beanName)) {//清除 allBeanNameByType//把单例池当中的 bean 也 removeresetBeanDefinition(beanName);}}

 this.beanDefinitionMap.put(beanName, beanDefinition);

 从这里可以看到bean已经存在到 IOC容器中,到此 AnnotatedBeanDefinitionReader 分析结束

接着看 ClassPathBeanDefinitionScanner 的构造方法

2.2  ClassPathBeanDefinitionScanner 构造方法

这个方法主要是创建BeanDefinition扫描器,可以用来扫描包或者类,继而转换为bd,spring默认的扫描器其实不是这个scanner对象, 而是在后面自己又重新new了一个ClassPathBeanDefinitionScanner, spring在执行工程后置处理器ConfigurationClassPostProcessor时,去扫描包时会new一个ClassPathBeanDefinitionScanner
这里的scanner仅仅是为了程序员可以手动调用AnnotationConfigApplicationContext对象的scan方法


所以这里不展开看了。

 

 

 3、最后回到我们最开始的地方, 可以看到 spring 初始化上下文已经有了,打个断点可以看到IOC容器已经实例化了一些对象,就是上面的6中默认bean,

截图:

参考博客:

1、https://blog.csdn.net/zzzzzyyyz/article/details/116999121

2、spring加载流程之AnnotatedBeanDefinitionReader_浴缸灬的博客-CSDN博客

3、SpringBoot源码深度剖析——@SpringBootApplication注解和new SpringApplication().run()方法深度解密_生活,没那么矫情的博客-CSDN博客

 

 

 

相关文章:

SpringBoot 源码分析初始化应用上下文(1)-createApplicationContext

前言&#xff1a;springBoot的版本是 2.2.4.RELEASE 一、入口 /*** Run the Spring application, creating and refreshing a new* {link ApplicationContext}.* param args the application arguments (usually passed from a Java main method)* return a running {link A…...

STM32队列

目录 什么是队列&#xff1f; 队列特点 1. 数据入队出队方式 2. 数据传递方式 3. 多任务访问 4. 出队、入队阻塞 队列相关 API 函数 1. 创建队列 参数&#xff1a; 2. 写队列 参数&#xff1a; 返回值&#xff1a; 3. 读队列 参数&#xff1a; 返回值&#xf…...

探索Beyond Compare:让文件比较和管理变得简单高效

在这个信息爆炸时代&#xff0c;我们的日常生活和工作中需要处理大量的数据和文档。在这个过程中&#xff0c;有时候我们会面临找出不同文件之间的差异、合并重复内容等需求。那么&#xff0c;有没有一款软件可以帮助我们轻松地完成这些任务呢&#xff1f;答案当然是肯定的&…...

动态网站Servelt基础

文章目录 一、Servlet基础&#xff08;一&#xff09;Servlet概述1、Servlet是什么2、Servlet容器3、Servlet应用程序的体系结构 &#xff08;二&#xff09;Servlet的特点1、功能强大2、可移植3、性能高效4、安全性高5、可扩展 &#xff08;三&#xff09;Servlet接口1、Servl…...

Docker 网络

Docker 网络实现原理 Docker使用Linux桥接&#xff0c;在宿主机虚拟一个Docker容器网桥(docker0)&#xff0c;Docker启动一个容器时会根据Docker网桥的网段分配给容器一个IP地址&#xff0c;称为Container-IP&#xff0c;同时Docker网桥是每个容器的默认网关。因为在同一宿主机…...

Tomcat的优化

Tomcat的优化 一、Tomcat 优化Tomcat 配置文件参数优化 二、系统内核优化三、Tomcat 配置 JVM 参数&#xff1a;参数含义 一、Tomcat 优化 Tomcat默认安装下的缺省配置并不适合生产环境&#xff0c;它可能会频繁出现假死现象需要重启&#xff0c;只有通过不断压测优化才能让它…...

一个问题来对比文心一言和chatgpt

问题&#xff1a; 请注意&#xff0c; 孩子不会说话&#xff0c;他无法用语言来回复妈妈的问题&#xff0c; 请生成以下剧本&#xff1a;一个妈妈和一岁不会说话的婴儿的日常vlog的剧本 文心一言 场景一&#xff1a;早晨 &#xff08;妈妈和孩子在客厅里醒来&#xff09; 妈妈&…...

防雪崩利器之Hystrix

Hystrix作为一个容错组件&#xff0c;本文从它的作用、熔断设计、工作流程和应用方面一一道来&#xff0c;帮助大家了解如何使用。 1、什么是灾难性雪崩效应 要讲Hystrix&#xff0c;我们就要讲一种场景&#xff0c;在微服务架构中&#xff0c;如果底层服务出现故障&#xff0…...

机器学习复习(上)

严正声明&#xff1a;本文的答案是ChatGPT的回答&#xff0c;仅供参考&#xff0c;不代表就是正确答案&#xff01;&#xff01;&#xff01; 1.解释什么是过拟合和欠拟合&#xff0c;如何降低过拟合? 过拟合&#xff08;overfitting&#xff09;指的是一个模型在训练数据上表…...

node笔记_express结合formidable实现前后端的文件上传

文章目录 ⭐前言⭐安装http请求的文件解析依赖库&#x1f496; 安装 formidable&#x1f496; node formidable接受formData上传参数 ⭐上传的页面搭建&#x1f496; vue2 element upload&#x1f496; node 渲染 上传文件 ⭐后端生成api上传文件到指定目录&#x1f496;完整的…...

CKA 09_Kubernetes工作负载与调度 资源调度 三类QoS request 资源需求 limit 资源限额

文章目录 1. 资源调度1.1 准备工作1.2 为什么需要 request 和 limit1.3 内存限制1.3.1 Brustable1.3.2 Guaranteed1.3.3 BestEffort1.3.4 当容器申请的资源超出 limit 和 request 1.4 CPU限制 1. 资源调度 1.1 准备工作 Kubernetes 采用 request 和 limit 两种限制类型来对资源…...

【pytorch】维度变换

【pytorch】维度变换 View操作unSqueeze操作图片处理的一个案例squeeze 维度删减操作维度扩展-expand维度扩展-repeat矩阵的转置操作-transpose View操作 将一个四维的张量&#xff08;b x c x h x w&#xff09;转换成一个二维的张量 对于四张图片 将每一张图像用一行向量进…...

vue3中的nextTick()

目录 nextTick() 方法用法回调函数方式使用await方式使用 实现原理使用nextTick() 方法时的注意事项 nextTick() 方法 nextTick() 方法是一个非常强大的工具&#xff0c;是一个等待下一次 DOM 更新刷新的工具方法。用于将一个函数以异步的方式推迟到下一个 DOM 更新周期执行。…...

高效学习传感器|霍尔式传感器

01、霍尔式传感器的工作原理 1●霍尔效应 霍尔式传感器的物理基础是霍尔效应。如图1所示&#xff0c;在一块长度为l、宽度为b、厚度为d的长方体导电板上&#xff0c;左、右、前、后侧面都安装上电极。在长度方向上通入电流I&#xff0c;在厚度方向施加磁感应强度为B的磁场。 ■…...

2023年前端面试高频考点HTML5+CSS3

目录 浏览器的渲染过程⭐⭐⭐ CSS 、JS 阻塞 DOM 解析和渲染 回流&#xff08;重排&#xff09;和重绘⭐⭐ 选择器 ID选择器、类选择器、标签选择器&#xff08;按优先级高到低排序&#xff09;⭐⭐ 特殊符号选择器&#xff08;&#xff1e;,,~&#xff0c;空格&#xff0…...

企业开源测试项目实战(附全套实战项目教程+视频+源码)

接口测试项目 1. No matching distribution found for itypes1.1.0 Could not find a version that satisfies the requirement itypes1.1.0 (from -r requirements.txt (line 8)) (from versions: ) No matching distribution found for itypes1.1.0 (from -r requirements.…...

信创办公–基于WPS的EXCEL最佳实践系列 (创建表格)

信创办公–基于WPS的EXCEL最佳实践系列 &#xff08;创建表格&#xff09; 目录 应用背景操作步骤1、新建空白工作簿并命名为“奖牌榜”2、使用模板新建工作簿3、新增一张工作表&#xff0c;并将工作簿的标签更改为红色4、复制与隐藏工作表5、添加工作簿属性值6、更改工作簿主题…...

四、HAL_驱动机械按键

1、开发环境。 (1)KeilMDK&#xff1a;V5.38.0.0 (2)STM32CubeMX&#xff1a;V6.8.1 (3)MCU&#xff1a;STM32F407ZGT6 2、机械按键简介 (1)按键内部是机械结构&#xff0c;也就是内部是没有电路的。按键按下内部引脚导通&#xff0c;松开内部断开。 3、实验目的&原理…...

机器学习实战六步法之数据收集方法(四)

要落地一个机器学习的项目&#xff0c;是有章可循的&#xff0c;通过这六个步骤&#xff0c;小白也能搞定机器学习。 看我闪电六连鞭&#xff01;&#x1f923; 数据收集 数据是机器学习的基础&#xff0c;没有数据一切都是空谈&#xff01;数据集的数据量和数据的质量往往决…...

神经网络:CNN中的filter,kernel_size,strides,padding对输出形状的影响

输入数据在经过卷积层后&#xff0c;形状一般会发生改变&#xff0c;而形状的变化往往与以下四个超参数有关。 1&#xff0c;filter&#xff08;out_channel&#xff09; 该超参数控制着输入数据经过卷积层中需要与几个卷积核进行运算&#xff0c;而输入数据与每个卷积核进行…...

Zustand 状态管理库:极简而强大的解决方案

Zustand 是一个轻量级、快速和可扩展的状态管理库&#xff0c;特别适合 React 应用。它以简洁的 API 和高效的性能解决了 Redux 等状态管理方案中的繁琐问题。 核心优势对比 基本使用指南 1. 创建 Store // store.js import create from zustandconst useStore create((set)…...

python/java环境配置

环境变量放一起 python&#xff1a; 1.首先下载Python Python下载地址&#xff1a;Download Python | Python.org downloads ---windows -- 64 2.安装Python 下面两个&#xff0c;然后自定义&#xff0c;全选 可以把前4个选上 3.环境配置 1&#xff09;搜高级系统设置 2…...

生成 Git SSH 证书

&#x1f511; 1. ​​生成 SSH 密钥对​​ 在终端&#xff08;Windows 使用 Git Bash&#xff0c;Mac/Linux 使用 Terminal&#xff09;执行命令&#xff1a; ssh-keygen -t rsa -b 4096 -C "your_emailexample.com" ​​参数说明​​&#xff1a; -t rsa&#x…...

【Go】3、Go语言进阶与依赖管理

前言 本系列文章参考自稀土掘金上的 【字节内部课】公开课&#xff0c;做自我学习总结整理。 Go语言并发编程 Go语言原生支持并发编程&#xff0c;它的核心机制是 Goroutine 协程、Channel 通道&#xff0c;并基于CSP&#xff08;Communicating Sequential Processes&#xff0…...

LINUX 69 FTP 客服管理系统 man 5 /etc/vsftpd/vsftpd.conf

FTP 客服管理系统 实现kefu123登录&#xff0c;不允许匿名访问&#xff0c;kefu只能访问/data/kefu目录&#xff0c;不能查看其他目录 创建账号密码 useradd kefu echo 123|passwd -stdin kefu [rootcode caozx26420]# echo 123|passwd --stdin kefu 更改用户 kefu 的密码…...

宇树科技,改名了!

提到国内具身智能和机器人领域的代表企业&#xff0c;那宇树科技&#xff08;Unitree&#xff09;必须名列其榜。 最近&#xff0c;宇树科技的一项新变动消息在业界引发了不少关注和讨论&#xff0c;即&#xff1a; 宇树向其合作伙伴发布了一封公司名称变更函称&#xff0c;因…...

go 里面的指针

指针 在 Go 中&#xff0c;指针&#xff08;pointer&#xff09;是一个变量的内存地址&#xff0c;就像 C 语言那样&#xff1a; a : 10 p : &a // p 是一个指向 a 的指针 fmt.Println(*p) // 输出 10&#xff0c;通过指针解引用• &a 表示获取变量 a 的地址 p 表示…...

Python 训练营打卡 Day 47

注意力热力图可视化 在day 46代码的基础上&#xff0c;对比不同卷积层热力图可视化的结果 import torch import torch.nn as nn import torch.optim as optim from torchvision import datasets, transforms from torch.utils.data import DataLoader import matplotlib.pypl…...

第一篇:Liunx环境下搭建PaddlePaddle 3.0基础环境(Liunx Centos8.5安装Python3.10+pip3.10)

第一篇&#xff1a;Liunx环境下搭建PaddlePaddle 3.0基础环境&#xff08;Liunx Centos8.5安装Python3.10pip3.10&#xff09; 一&#xff1a;前言二&#xff1a;安装编译依赖二&#xff1a;安装Python3.10三&#xff1a;安装PIP3.10四&#xff1a;安装Paddlepaddle基础框架4.1…...

2.3 物理层设备

在这个视频中&#xff0c;我们要学习工作在物理层的两种网络设备&#xff0c;分别是中继器和集线器。首先来看中继器。在计算机网络中两个节点之间&#xff0c;需要通过物理传输媒体或者说物理传输介质进行连接。像同轴电缆、双绞线就是典型的传输介质&#xff0c;假设A节点要给…...