Announcement Announcement Module
Collapse
No announcement yet.
How to autowire an alias bean? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to autowire an alias bean?

    Hi,

    I am trying to figure out if/how I can autowire a bean that has been aliased.

    For example:
    Code:
    	<bean id="fwl.config.StandardSystemConfiguration" class="org.apache.commons.configuration.CompositeConfiguration" autowire-candidate="true" scope="singleton">
    		<constructor-arg>
    			<list>
    				<ref bean="fwl.config.SystemPropertiesConfiguration"/>
    				<ref bean="fwl.config.DefaultsConfiguration"/>
    				<ref bean="fwl.config.SystemContextConfiguration"/>
    			</list>
    		</constructor-arg>
    	</bean>
    	
    	<!-- standard configuration alias since this object is bound to be used quite often -->
    	<alias alias="configuration" name="fwl.config.StandardSystemConfiguration" />
    Is there anyway I can autowire the "configuration" bean? Does the alias help at all for the autowiring, or it serves no purpose?

    Thanks,

    Eric

  • #2
    If you use @Autowired by default it uses by type, so in that case the alias is pretty much useless. You can add in an @Qualifier which contains the name of the bean you want to wire.

    Comment

    Working...
    X