Spring: Getting FactoryBean object instead of FactoryBean.getObject()

前端 未结 2 1813
轮回少年
轮回少年 2020-12-31 10:06

Short question: If I have class that impelemnts FactoryBean interface, how can I get from FactoryBean object itself instead of FactoryBean.getObject()?

相关标签:
2条回答
  • 2020-12-31 10:39

    It's the & (ampersand), not the At-symbol, see Spring Framework documentation: Customizing instantiation logic using FactoryBeans

    <property name="factoryBean" ref="&amp;theFactoryBean" />
    
    0 讨论(0)
  • 2020-12-31 10:42

    You can get the factory bean itself using the & syntax in the spring config:

    <property name="factoryBean" ref="&theFactoryBean" />
    

    as opposed to:

    <property name="createdBean" ref="theFactoryBean" />
    
    0 讨论(0)
提交回复
热议问题