目录
一、Spring Bean的定义
Spring Bean是Spring框架中的核心概念,它是Spring容器中的一个可重用组件,通常是一个Java类的实例。Bean的生命周期由Spring容器管理,从创建到初始化,再到使用和销毁,每个阶段都有特定的方法和事件。
二、Bean的创建
(一)基于XML配置
在Spring的XML配置文件中,使用<bean>标签定义Bean。
<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
https://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="myBean" class="com.example.MyBean"/>

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



