惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
博客园 - 叶小钗
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
博客园_首页
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)
Help Net Security
Help Net Security
Cloudbric
Cloudbric
AI
AI
N
News | PayPal Newsroom
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
Forbes - Security
Forbes - Security
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
SecWiki News
SecWiki News
H
Heimdal Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
V
V2EX
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
S
Security Affairs
L
LangChain Blog
The Hacker News
The Hacker News
F
Full Disclosure
aimingoo的专栏
aimingoo的专栏
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
Webroot Blog
Webroot Blog
A
About on SuperTechFans
H
Hacker News: Front Page
Cyberwarzone
Cyberwarzone
WordPress大学
WordPress大学
L
LINUX DO - 热门话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Attack and Defense Labs
Attack and Defense Labs
M
MIT News - Artificial intelligence

博客园 - 走到天亮

设计模式之“适配器模式” 设计模式之“门面模式” 设计模式之“抽象工厂模式” 设计模式之“单例模式” 设计模式之“代理模式” 设计模式之“策略模式” 《C# to IL》第三章 选择和循环 《C# to IL》第二章 IL基础 《C# to IL》第一章 IL入门 淘宝下单高并发解决方案(转载) java linux 配置环境 Spring Aop之(二)--Aop 切面声明和通知 Spring aop Spring RegexpMethodPointcutAdvisor和NameMatchMethodPointcutAdvisor Spring BeanNameAutoProxyCreator 与 ProxyFactoryBean CentOS的IP配置专题 【阿里的感悟】质量该如何做? .(转载) Ubuntu开机自动启动script(2) Ubuntu开机自动启动Script
Spring Bean属性绑定Bean返回值
走到天亮 · 2012-08-09 · via 博客园 - 走到天亮

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>

 

posted @ 2012-08-09 18:44  走到天亮  阅读(1086)  评论()    收藏  举报