gpt4 book ai didi

带参数的Spring查找方法注入(inject)

转载 作者:行者123 更新时间:2023-12-04 12:37:35 24 4
gpt4 key购买 nike

有没有办法使用带有参数的 Spring 查找方法注入(inject)?例如,我希望能够实例化原型(prototype)范围的 bean,同时通过构造函数向它们传递任意参数。

最佳答案

看起来这个重要功能终于在 Spring 4.1.0.RC2 中添加了。我已经对其进行了测试,它似乎可以工作。

它是作为 JIRA 票证的一部分添加的 SPR-7431 ("Passing lookup-method arguments to created bean constructor") :

<lookup-method/> should allow specifying any number of parameters. These parameters should be passed directly to the constructor of the newly created bean.



有关如何最终添加该功能的更多信息, this blog post是开JIRA票的那个人写的。

关于带参数的Spring查找方法注入(inject),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4337668/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com