<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--
使用bean 的 scope 属性配置bean的作用域
singleton: 默认值 在创建容器时创建bean实例 在整个生命周期内只创建这一个bean 单例模式
prototype: 原形的 容器初始化的时候不创建bean 而在每次请求的时候都创建一个新的bean实例
-->
<bean id="car"
class="com.atguigu.spring.beans.scope.Car"
scope="prototype">
<property name="brand" value="Audi"></property>
<property name="price" value="300000"></property>
</bean>
</beans>
spring-scop (单例模式?)
最新推荐文章于 2021-03-05 14:40:31 发布