zoukankan      html  css  js  c++  java
  • Spring Bean属性绑定Bean返回值

    MethodInvokingFactoryBean 工厂bean,可以将指定方法返回值注入成为目标Bean的属性值,MethodInvokingFactoryBean用来获得指定方法的返回值,该方法可以是静态方法
    也可以是实例方法。
    获得的方法返回值既可以被注入到指定Bean实例的指定属性,也可以直接定义成Bean实例。
     

    <bean id="testfunc"  class="spring.aop.TestFunc"/>

        <!--动态方法调用-->
        <bean id="testInvok"   class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">  
           <property name="targetObject" >
           <ref local="testfunc"/>
           </property>
           <property name="targetMethod" value="test1"></property>
           <property name="arguments">
           <list>
              <value>test</value>
           </list>
           </property>
       </bean>

       <!--静态方法调用-->
        <bean id="testInvok"   class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">  
           <property name="targetClass" >//-注意这里的区别
           <ref local="testfunc"/>
           </property>
           <property name="targetMethod" value="getname"></property>
           <property name="arguments">
           <list>
              <value>test</value>
           </list>
           </property>
       </bean>
       <!--Bean属性绑定Bean返回值-->
    <bean id="testfunc"  class="spring.aop.TestFunc">
      <property name="name"
    ref="testInvok" />

    </bean>

     

       

  • 相关阅读:
    5月13日工作日志(需求规格说明书4.0)
    第十次会议
    5月21日日志
    5月12日工作日志
    关于游戏平衡性——王者荣耀英雄伤害数值参考
    每天一点新东西(1)
    我在都匀做网优(补)
    我在都匀做网优
    不算新的开始
    input的focus事件时,鼠标光标在最后
  • 原文地址:https://www.cnblogs.com/65702708/p/2630769.html
Copyright © 2011-2022 走看看