简体   繁体   中英

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":

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

All libraries but one correctly use @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? 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 name="statFactory" alias="StatFactory"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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