Bean scopes:

singleton: single embodiment, refers to a container exists only one Bean

prototype: every request (each time) to create a new instance

Bean.xml written in a way

<?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>
Published 84 original articles · won praise 0 · Views 693

Guess you like

Origin blog.csdn.net/qq_38405199/article/details/103712165
Recommended