SpringBean 的生命周期

SpringBean生命周期详解 SpringBean生命周期详解 一、简述: Spring是我们每天都在使用的框架,Bean是被Spring管理的Java对象,是Spring框架最重要的部分之一,那么让我们一起了解一下Spring中Bean的生命周期是怎样的吧 二、流程图 我们先从宏观的角度看一下Spring的生命周期: ![在这里插入图片描述](https://img-blog.csdnimg.cn/20201028174058916.png?x-oss-process=image/watermark,t ype_ZmFuZ3poZW5 阅读详情

一、整体流程

【Instantiation 实例化阶段】

  1. Spring 读取 xml 配置文件,容器就会调用doCreateBean方法进行实例化。底层是通过工厂+反射完成的创建。

【Populate 设置属性阶段】

  1. 利用依赖注入完成 Bean 中所有属性值的配置注入。

【Initialization 初始化阶段】

  1. 如果 Bean 实现了 BeanNameAware 接口,则 Spring 调用 Bean 的 setBeanName() 传入当前 Bean 的 id 值。
  2. 如果 Bean 实现了 BeanClassLoaderAware 接口,则执行 setBeanClassLoader()。
  3. 如果 Bean 实现了 BeanFactoryAware 接口,则 Spring 调用 setBeanFactory() 传入当前工厂实例的引用。
  4. 如果 Bean 实现了 ApplicationContextAware 接口,则 Spring 调用 setApplicationContext() 传入当前 ApplicationContext 实例的引用。
  5. 如果实现了 BeanPostProcessor 的前置处理方法,执行postProcessBeforeInitialization()对 bean 进行前置初始化。此处非常重要,Spring 的 AOP 就是利用它实现的。
  6. 如果 Bean 实现了 InitializingBean 接口,则 Spring 将调用 afterPropertiesSet()。该方法是在所有bean对象完成实例化后执行的。如果在配置文件中通过 init-method 属性指定了初始化方法,则继续调用该方法。
  7. 如果实现了 BeanPostProcessor 的后置处理方法,执行postProcessAfterInitialization()可以获取该bean对象添加一些默认值的属性,甚至可以返回一个代理对象。此时,Bean 已经可以被应用系统使用了。

初始化方法有三个(顺序调用):

  • @PostConstruct 注解标注的方法
  • InitializingBean 的 afterPropertiesSet()
  • 配置的 init-method

三个方法效果都是一样的,开发中选择其中一种方式就行,一般选择1、3方法中的一个。

【Destruction 销毁阶段】

  1. 如果 Bean 实现了 DisposableBean 接口,则 Spring 会调用 destory() 将 Spring 中的 Bean 销毁;如果在配置文件中通过 destory-method 属性指定了 Bean 的销毁方法,则 Spring 将继续调用该方法。

销毁方法有三个(顺序调用):

  • @PreDestroy 注解标注的方法
  • DisposableBean 接口的 destroy 方法
  • 配置的 destroy-method

三个方法效果都是一样的,开发中选择其中一种方式就行,一般选择1、3方法中的一个。

注意:
Spring 为 Bean 提供了全面细致的生命周期过程,通过实现特定的接口或 <bean> 的属性设置,都可以对 Bean 的生命周期过程产生影响。虽然可以配置 <bean> 的属性,但是建议不要过多使用 Bean 实现接口,因为会导致代码和 Spring 的聚合过于紧密。

二、说明

了解 SpringBean 生命周期的意义,是可以在其存活期间的指定时刻完成一些相关操作。这种时刻可能有很多,一般情况下,会在 Bean 被初始化后和被销毁前执行一些相关操作。一般 JavaBean 的生命周期很简单,使用关键字 new 实例化 Bean,当不需要该 Bean 时,由 Java 自动进行垃圾回收。而 Spring 根据Bean的作用域来选择管理。对于 singleton 作用域的 Bean,Spring 能够精确地知道该 Bean 何时被创建,何时初始化完成,以及何时被销毁。而对于 prototype 作用域的 Bean,Spring 只负责创建,当容器创建了 Bean 的实例后,Bean 的实例就交给客户端代码管理,Spring 容器将不再跟踪其生命周期。Spring Bean 的生命周期可以类比人的一生:

实例化:
第 1 步,实例化一个 Bean 对象
出生:作为一个自然人降临在这个世界

属性赋值:
第 2 步,为 Bean 设置相关属性和依赖
登记:登记身份证号,姓名,正式成为人类社会的一份子

初始化:
第 3、4 步为在初始化前执行,5、6步是真正的初始化,第 7 步在初始化后执行,初始化完成之后,Bean就可以被使用了。
成长:接受教育,成为对社会有用的人

使用:
工作:为社会创造价值

销毁:
第 8~10步,第8步其实也可以算到销毁阶段,但不是真正意义上的销毁,而是先在使用前注册了销毁的相关调用接口,为了后面第9、10步真正销毁 Bean 时再执行相应的方法。
死亡:人死如灯灭,不过人这盏灯灭了,还要把灯台埋起来

Bean实例化的时机分为两种,BeanFactory管理的Bean是在使用到的时候才会实例化,ApplicantContext管理的Bean在容器初始化的时候就会完成实例化。BeanFactory就是相对原始一些的社会,ApplicantContext是发达健全的现代社会。

三、理解

在这里插入图片描述

  1. Bean容器在配置文件中找到Person Bean的定义,这个可以说是妈妈怀上了。

  2. Bean容器使用Java 反射API创建Bean的实例,孩子出生了。

  3. Person声明了属性no、name,它们会被设置,相当于注册身份证号和姓名。如果属性本身是Bean,则将对其进行解析和设置。

  4. Person类实现了BeanNameAware接口,通过传递Bean的名称来调用setBeanName(),相当于起个学名。

  5. Person类实现了BeanFactoryAware接口,通过传递BeanFactory对象的实例来调用setBeanFactory(),就像是选了一个学校。

  6. PersonBean实现了BeanPostProcessor接口,在初始化之前调用postProcessBeforeInitialization(),相当于入学报名。

  7. PersonBean类实现了InitializingBean接口,在设置了配置文件中定义的所有Bean属性后,调用afterPropertiesSet(),就像是入学登记。

  8. 配置文件中的Bean定义包含init-method属性,该属性的值将解析为Person类中的方法名称,初始化的时候会调用这个方法,成长不是走个流程,还需要自己不断努力。

  9. Bean Factory对象如果附加了Bean 后置处理器,就会调用postProcessAfterInitialization(),毕业了,总得拿个证。

  10. Person类实现了DisposableBean接口,则当Application不再需要Bean引用时,将调用destroy(),简单说,就是人蹬腿儿了。

  11. 配置文件中的Person Bean定义包含destroy-method属性,所以会调用Person类中的相应方法定义,相当于选好地儿,埋了。

创建一个PersonBean,让它实现几个特殊的接口,来观察一下它的生命周期。

package ioc;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


public class PersonBean implements InitializingBean, BeanFactoryAware, BeanNameAware, DisposableBean {
    /**
     * 身份证号
     */
    private Integer id;
    /**
     * 姓名
     */
    private String name;

    public PersonBean() {
        System.out.println("1.调用构造方法:我出生了!");
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        System.out.println("2.设置属性:我的名字叫" + name);
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("3.调用BeanNameAware#setBeanName方法:我要上学了,起了个学名");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("4.调用BeanFactoryAware#setBeanFactory方法:选好学校了");
    }

    @PostConstruct
    public void initPostConstruct() {
        System.out.println("6-1.注解@PostConstruct初始化");
    }

    @Override
    public void afterPropertiesSet() {
        System.out.println("6-2.InitializingBean#afterPropertiesSet方法:入学登记");
    }

    //通过<bean>的init-method属性指定的初始化方法
    public void initMethod() {
        System.out.println("6-3.init-method:xml配置初始化");
    }

    public void work() {
        System.out.println("8.Bean使用中:work,只有对社会没有用的人才放假。。");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("9-1.注解销毁@PreDestroy");
    }

    @Override
    public void destroy() {
        System.out.println("9-2.DisposableBean#destroy方法:平淡的一生落幕了。");
    }

    //通过<bean>的destroy-method属性指定的销毁方法
    public void destroyMethod() {
        System.out.println("9-3.destroy-method:xml配置销毁");
    }

}

实现了InitializingBean、BeanFactoryAware、BeanNameAware、DisposableBean四个接口。定义了id、name两个属性和对应的getter、setter方法。定义了一个实例方法work。

MyBeanPostProcessor:

public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("5.BeanPostProcessor.postProcessBeforeInitialization方法:到学校报名啦");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("8.BeanPostProcessor#postProcessAfterInitialization方法:终于毕业,拿到毕业证啦!");
        return bean;
    }
}

定义配置文件applicationContext.xml。定义init-method和destroy-method。

<?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.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean name="personBean" class="ioc.PersonBean" init-method="initMethod" destroy-method="destroyMethod">
        <property name="id" value="666888"/>
        <property name="name" value="xxp"/>
    </bean>
    
    <!-- 配置注解@PostConstruct、@PreDestroy用 -->
    <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
    <bean name="myBeanPostProcessor" class="ioc.MyBeanPostProcessor"/>
</beans>

测试:

@Test
public void test1() {
    System.out.println("Spring容器初始化===========================");
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    System.out.println("Spring容器初始化完毕========================");
    PersonBean personBean = (PersonBean) context.getBean("personBean");
    personBean.work();
    context.destroy();
    System.out.println("Spring容器关闭==========================");
    context.close();
}

运行结果:

Spring容器初始化===========================
.
.
.
org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
1.调用构造方法:我出生了!
2.设置属性:我的名字叫xxp
3.调用BeanNameAware#setBeanName方法:我要上学了,起了个学名
4.调用BeanFactoryAware#setBeanFactory方法:选好学校了
5.BeanPostProcessor.postProcessBeforeInitialization方法:到学校报名啦
6-1.注解@PostConstruct初始化
6-2.InitializingBean#afterPropertiesSet方法:入学登记
6-3.init-method:xml配置初始化
7.BeanPostProcessor#postProcessAfterInitialization方法:终于毕业,拿到毕业证啦!
Spring容器初始化完毕========================
8.Bean使用中:work,只有对社会没有用的人才放假。。
十月 11, 2022 10:13:28 下午 org.springframework.context.support.AbstractApplicationContext doClose
信息: Closing org.springframework.context.support.ClassPathXmlApplicationContext@67117f44: startup date [Tue Oct 11 22:13:27 CST 2022]; root of context hierarchy
9-1.注解销毁@PreDestroy
9-2.DisposableBean#destroy方法:平淡的一生落幕了。
9-3.destroy-method:xml配置销毁
Spring容器关闭==========================

Process finished with exit code 0

AbstractApplicationContext类的refresh方法,是AplicationContext容器初始化的关键点。方法调用了finishBeanFactoryInitialization方法,这个方法里调用了getBean方法,getBean方法里调用了AbstractBeanFactory的getBean方法。
在这里插入图片描述

经过一系列调用,到达了Bean创建的方法:doGetBean(),该方法里可以看到Bean的实例化,赋值、初始化的过程。至于最终的销毁可关注下ConfigurableApplicationContext#close()。

四、bean 的初始化时机

bean 对象无外乎是在以下两个时刻进行实例化的:

  1. Spring 容器启动时。
  2. 调用 getBean() 时。

bean 对象在何时进行实例化,这与 Bean 的作用域有关系。测试如下:

public class PersonServiceBean implements PersonService {    
  public PersonServiceBean() {  
    System.out.println("我被实例化了");   
  }     
  @Override    
  public void save() {     
    System.out.println("我是save()"); 
  }
}

1️⃣当 Spring 的配置文件——beans.xml 的内容为:

 <?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.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="personService"
	class="cn.service.impl.PersonServiceBean"></bean> 

</beans>

即 bean 的作用域为 singleton 时,修改 SpringTest 类的代码为:

public class SpringTest {     
   @Test    
    public void test() {        
       // 实例化Spring容器   
       ApplicationContext ctx = 
       	new ClassPathXmlApplicationContext("beans.xml");
    } 
}

test() 输出:我被实例化了

这说明当 bean 的作用域为 singleton 时,bean 对象是在 Spring 容器启动时就进行创建了。即默认情况下会在容器启动时初始化 bean,但也可以指定 bean 节点的lazy-init=“true”来延迟初始化 bean。此时,只有初次获取 bean 时才初始化 bean。修改 Spring 配置文件 beans.xml:

<?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.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">     

<bean id="personService"
	class="cn.service.impl.PersonServiceBean" 
		lazy-init="true"></bean>

</beans>

lazy-init=”true”指定了不要在 Spring 容器启动时对该 bean 进行实例化。此时,执行 test(),就不会输出我被实例化了。这时,修改 SpringTest:

public class SpringTest {     
    @Test   
    public void test() {        
     //实例化Spring容器
     ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
     //从Spring容器取得bean
     PersonService personService = (PersonService) ctx.getBean("personService");
    } 
}

再次执行 test(),输出:我被实例化了

若对所有 bean 都应用延迟初始化,可以在根节点 beans 设置default-lazy-init=“true”,如下:

<?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.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd" 
default-lazy-init="true">     
...... 
</beans>

2️⃣当 Spring 的配置文件——beans.xml 的内容为:

<?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.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">   
  
<bean id="personService"
	class="cn.service.impl.PersonServiceBean" 
			scope="prototype"></bean>
</beans>

即 bean 的作用域为 prototype 时,若 SpringTest 类的代码为:

public class SpringTest {     
  @Test    
  public void test() {        
    // 实例化Spring容器 
    ApplicationContext ctx = 
    	new ClassPathXmlApplicationContext("beans.xml"); 
  } 
}

执行 test(),没有输出这句话:我被实例化了。这就说明当 bean 的作用域为 prototype 时,bean 对象并不会在 Spring 容器启动时就进行创建。修改 SpringTest:

public class SpringTest {     
    @Test    
     public void test() {        
       // 实例化Spring容器
       ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); 
       // 从Spring容器取得bean
       PersonService personService = (PersonService) ctx.getBean("personService"); 
  }
}

再次执行 test(),输出:我被实例化了。证实了当 bean 的作用域为 prototype 时,bean 对象将会在调用 getBean() 时进行创建。

五、指定bean的初始化方法和销毁方法

为了达到在 bean 被初始化的时候,就初始化某些资源的目的,可修改 PersonServiceBean 类的代码为:

public class PersonServiceBean implements PersonService {
    public void init() {
        System.out.println("初始化某些资源");
    }
    public PersonServiceBean() {
        System.out.println("我被实例化了");
    }
    @Override
    public void save() {
        System.out.println("我是save()");
    }
}

这样,目的就具体地成为:当 Spring 容器初始化 PersonServiceBean 对象之后,就要执行该对象的 init()。修改 Spring 配置文件 beans.xml:

<?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.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">    
 
<bean id="personService"
	class="cn.service.impl.PersonServiceBean" 
lazy-init="false" init-method="init" />

</beans>

若 SpringTest 类的代码为:

public class SpringTest {
    @Test
    public void test() {
        // 实例化Spring容器     
        ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
    }
}

执行 test(),输出: 输出

现在又希望在 bean 被销毁的时候,就释放或关闭某些资源。修改 PersonServiceBean:

public class PersonServiceBean implements PersonService {
    public void init() {
        System.out.println("初始化某些资源");
    }
    public PersonServiceBean() {
        System.out.println("我被实例化了");
    }
    @Override
    public void save() {
        System.out.println("我是save()");
    }
    public void destroy() {
        System.out.println("释放初始化的资源");
    }
}

bean 对象到底是什么时候销毁的呢?答案是:如果没有人为地删除它,默认该 bean 一直在 Spring 容器中,也就是说随着 Spring 容器的关闭,该 bean 才会被销毁。修改 Spring 配置文件 beans.xml:

<?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.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">     

<bean id="personService" class="cn.service.impl.PersonServiceBean" 
lazy-init="false" init-method="init" destroy-method="destroy" /> 

</beans>

最后,修改 SpringTest:

public class SpringTest {
    @Test
    public void test() {
        // ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); 
        // 实例化Spring容器         
        AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        // 正常关闭Spring容器  
        ctx.close();
    }
}

执行 test(),输出:输出
这就是 Spring 管理的 Bean 的生命周期。

UDS诊断入门第一课:手把手教你玩转0x10会话控制服务(附ISO14229实战解析) 刚接触汽车电子诊断的工程师们,往往会被厚厚的ISO 14229标准文档和各种专业术语吓退。但就像学习编程要从"Hello World"开始一样,掌握UDS协议的最佳切入点就是0x10诊断会话控制服务。这个看似简单的服务,实际上是整个诊断系统的"钥匙"——它决定了ECU(电子控制单元)当前处于何种工作模式,直接影响着其他诊断服务的可用性。 在实际车辆诊断中,ECU默认处于DefaultSession模式,这种模式下许多高级诊断功能是被禁用的。想象一下你正在开发一个需要刷写ECU固件的工具,如果连最基本的会 阅读详情

相关推荐

02-基于ART-PI开发板创建USB CDC 虚拟串口设备

本例在ART-PI开发板上,基于RT-Thread 5.0,5虚拟了一个USB32 CDC串口设备。

arm_fan的专栏 1890

数据库索引采用B+树的主要原因

B树在提高了IO性能的同时并没有解决元素遍历的底下的问题,正是为了解决这个问题,B+树应用而生。B+树只需要去遍历叶子结点就可以实现遍历整棵树的。而在数据库中基于范围的查找是非常频繁的,而B树不支持这样的操作或者说效率比较低下。 1、 B+树的磁盘读写代价更低:B+树的内部节点并没有指向关键字具体信息的指针,因此其内部节点相对B树更小,如果把所有同一内部节点的关键字存放在同一盘块中,那么盘块所能容纳的关键字数量也越多,一次性读入内存的需要查找的关键字也就越多,相对IO读写次数就降低了。 2、B+树的

qq_44194341的博客 3984

AD7920实战:从咪头到ADC的音频信号采集电路设计全解析(附电路图)

本文详细解析了基于AD7920 ADC芯片的音频信号采集电路设计全流程。从驻极体咪头的驱动、AD8542运放的两级增益与偏置设计,到关键的抗混叠滤波器配置,以及ADC接口的驱动缓冲与PCB布局要点,提供了完整的实战指南与电路图,帮助开发者实现高质量音频信号采集。

red88的博客 832

字节面试题: Mysql索引结构,为什么要用b+树?

在数据库管理系统中,索引是一种数据结构,用于快速定位和访问数据库表中的特定记录。它类似于书籍的目录,可以帮助数据库系统快速定位到数据所在的位置,而不必扫描整个数据表。MySQL支持多种类型的索引,包括主键索引、唯一索引、普通索引和全文索引等。

jakelihua 1287

⭐️白嫖的阿里云认证⭐️ 【真题&参考答案】:大模型Clouder认证:利用大模型提升内容生产能力

【摘要】真题「大模型Clouder认证:利用大模型提升内容生产能力」

davidkorhenn的博客 1961

【PLC】三菱plc控件安装 component Movedata had the following error ... Error Number:-119

Windows 10 专业版/企业版本版本号:22H2操作系统内部版本:19045.3448。

少莫千华 8017

MySQL 索引:索引为什么使用 B+树?

B 树中每个节点(包括叶节点和非叶节点)都存储真实的数据,B+树中只有叶子节点存储真实的数据,非叶节点只存储键。红黑树保证最长路径不超过最短路径的二倍,因而近似平衡(最短路径就是全黑节点,最长路径就是一个红节点一个黑节点,当从根节点到叶子节点的路径上黑色节点相同时,最长路径刚好是最短路径的两倍):通过舍弃严格的平衡和引入红黑节点,解决了 AVL 旋转效率过低的问题,但是在磁盘等场景下,树仍然太高,IO 次数太多;从任一节点到其每个叶子的所有简单路径都包含相同数目的黑色节点(简称黑高)。

一蓑烟雨任平生 995

为什么我的Win11家庭版找不到BitLocker?教你两种强制关闭加密的隐藏方法

本文解释了Win11家庭版为何缺少BitLocker功能,并提供了两种强制关闭加密的隐藏方法。通过注册表修改和PowerShell命令,用户可以调出隐藏的加密控制面板或直接操控加密引擎,解决家庭版设备加密的管理难题。

weixin_42535703的博客 1814

MySQL 索引结构用B+树的原因

MySQL 的基本存储结构是页(记录都存在页里边): 各个数据页可以组成一个双向链表 每个数据页中的记录又可以组成一个单向链表 每个数据页都会为存储在它里边的记录生成一个页目录,在通过主键查找某条记录的时候可以在页目录中使用二分法快速定位到对应的槽,然后再遍历该槽对应分组中的记录即可快速找到指定的记录。 所以说,如果写select * from tab where name = 'xxx'这样没有进行任何优化的 sql 语句,默认会这样做: 定位到记录所在的页:需要遍历双向链表,找到所在的页。 从所在

ChineseSoftware的博客 3392

Python 爬虫实战:抓取悦动圈跑步爱好者运动轨迹数据,规划健身路线

通过本次 Python 爬虫实战,我们学习了如何使用 Python 抓取悦动圈跑步爱好者的运动轨迹数据,并基于这些数据进行分析和处理,最终规划出健身路线。在这个过程中,我们掌握了requests、BeautifulSoup、pandas和matplotlib等库的基本使用方法,了解了爬虫的基本原理和流程。希望本文能够帮助你更好地理解和应用 Python 爬虫技术,在数据处理和分析领域取得更多的成果。

u014481728的博客 2390

【CANoe示例分析】0002_SOMEIPDemo

该工程由Vector官方提供,作为仿真SOME/IP节点的示例。Demo中介绍了两种仿真SOME/IP节点的方法,一种是基于arxml数据库的仿真,另一种是没有数据库(arxml、fibex)的仿真。无论是哪种形式的仿真,如果想要通过CAPL程序接收或者发送SOME/IP信息,都需要添加交互层的信息,这些信息可以通过添加DLL文件实现,DLL文件路径在CANoe安装目录下的Exec32文件中。

jasonj333 3525

MySQL学习笔记5:为什么MySQL使用B+树作为索引

B+树

虽然但是 568

OMAPL138使用UPP读写测试

UPP测试代码 #include "hw_types.h" // 宏命令 #include "hw_syscfg0_OMAPL138.h" // 系统配置模块寄存器 #include "soc_OMAPL138.h" // DSP C6748 外设寄存器 #include "psc.h" // 电源与睡眠控制宏及设备抽象层函数声明 #include "interrupt.h" // DSP C6748 中断相关应用程序接...

wangjie36的博客 1195

SpringBean的生命周期

SpringBean的生命周期详情提供一种配置方式,在XML配置中指定Bean的初始化方法。如果Bean在配置文件中定义了初始化方法那么该方法会被调用。在的invokelnitMethods方法中调用如果Bean在配置文件中定义了销毁方法,那么该方法会被调用在的destroy方法中实现可以看到,整Bean的创建的过程都依赖于这个类,而销毁主要依赖这个类的入口处,doCreateBean的核心代码如下,其中包含了实例化、设置属性值、初始化Bean以及注册销毁回调的几个核心方法。

蒾酒的博客 2334

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

springbean的生命周期_一步一步,带你了解SpringBean的生命周期

推荐阅读:Spring全家桶笔记:Spring+Spring Boot+Spring Cloud+Spring MVC一个SpringBoot问题就干趴下了?我却凭着这份PDF文档吊打面试官.SpringBean的生命周期在面试中,我们经常会被问到一个问题,就是SpringBean的生命周期。用大白话说,就是说其在创造到销毁按顺序调用了什么方法,在我刚开始学了,一般就是对着标准答案去硬背,完全不了...

weixin_39596975的博客 103

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

SpringBean生命周期

SpringBean声明周期

qq_44863031的博客 532

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

《面试1v1》SpringBean生命周期

候选人:23.SpringBean生命周期

JavaPub 1407

springBean生命周期

一、springBean的生命周期 1、 启动spring容器,也就是创建beanFactory(bean工厂), 一般用的是beanFactory的子类applicationcontext, applicationcontext比一般的beanFactory要多很多功能,比如aop、事件等。 通过applicationcontext加载配置文件,或者利用注解的方式扫描将bean 的配置信息加载到spring容器里面。 2、 加载之后,spring容器会将这些

zhangCheng的博客 2万+

SpringBean的生命周期详解

在Spring生态环境中,SpringBean是除了IoC、AOP两个核心概念之外另一个重要概念,同时SpringBean的生命周期也是面试现场中的常客,而这一概念在Spring中又是零星分散在容器的各个阶段(源码的各个类中),查询起来比较复杂。因此,这里对SpringBean的生命周期进行一系列的总结,以供参考。

qq_43408971的博客 766

SpringBean的生命周期,以及怎么记忆

SpringBean的生命周期,以及怎么记忆

不定时分享最优质的网络技术与教程,满满的干货。 315
上一篇: MyBatis 配置 resultType
下一篇: MySQL中创建时间和更新时间的自动更新
JFS_Study
博客等级 码龄6年 363粉丝 359原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JFS_Study

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值