Spring member variable of a bean is assigned with the method of another bean

The beans in the spring configuration directly refer to the property values ​​of other beans to assign them to the properties of the current bean, or they can directly call the methods of other beans to get the return value to assign to the properties of the current bean, and can pass parameters, which saves the The bean that needs to get the property value is injected into the bean.
    <bean id="bean1" class="com.service.test.Bean1">  
    </bean>  
    <bean id="bean2" class="com.service.test.Bean2">  
        <property name="v1" value="#{bean1.v1}"/>  
        <property name="v2" value="#{bean1.getV1()}"/>  
        <property name="v3" value="#{bean1.getTestValue(3)}"/>  
        <property name="v4Str" value="#{'Hello '+bean1.getTestValue2('baby')}"/>  
    </bean>  

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326561283&siteId=291194637