简体   繁体   English

Spring 3.1:具有多个@Qualifier引用指向相同的Bean ID

[英]Spring 3.1: Have Multiple @Qualifier References Point to Same Bean ID

I am working with multiple shared jar libraries that I cannot recompile, and I need them to all use the same bean "StatFactory": 我正在使用多个无法重新编译的共享jar库,我需要它们全部使用同一个bean“ StatFactory”:

<bean id="StatFactory" class="com.tastytoast.helper.StatFactory">

All libraries but one correctly use @Qualifier("StatFactory") . 除一个库外,所有库均正确使用@Qualifier("StatFactory")

@Qualifier("StatFactory")
@Autowired
private StatFactory statFactory;

Is there any way to get the rebel library which uses @Qualifer("statFactory") to link to the "StatFactory" bean? 有没有办法获取使用@Qualifer("statFactory")链接到“ StatFactory” bean的反叛者库? I have looked online and there does not seem to be mention of it. 我在网上看过,似乎没有提及。

For example, something like this: 例如,如下所示:

<bean id="statFactory" redirect-to="StatFactory">

Thanks! 谢谢!

Use an alias can do the trick. 使用别名可以解决问题。
An <alias /> allow you to refer to a named bean with another name <alias />允许您使用其他名称引用命名的bean

<alias name="statFactory" alias="StatFactory"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM