<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>
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.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326550477&siteId=291194637
Ranking