Bean的作用域:
singleton:单例,指一个Bean容器中只存在一份
prototype:每次请求(每次使用)创建新的实例
Bean.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-3.0.xsd"> <bean id="sayHelloId" class="IOC.bbeanScope.SayHello" scope="singleton"> <property name="message" value="Hello To SayHello!"/> </bean> <bean id="sayHelloId2" class="IOC.bbeanScope.SayHello" scope="prototype"> <property name="message" value="Hello To SayHello!"/> </bean> </beans>