Mixing auto and  explicit wiring

Posted on 2011-05-04
Last Modified: 2012-05-11
Mixing auto, explicit wiring

I was reading folowing lines and I did not understand clearly.
Mixing automatic and explicit wiring is also a great way to deal with ambiguous
autowiring that may occur when autowiring using byType.
Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
Question by:gudii9
    1 Comment
    LVL 47

    Accepted Solution


    This is a good explanation from

    For example, to explicitly wire Kenny’s instrument property even though he is

    set to autowire by type, use this code:

    <bean id="kenny" class="com.springinaction.springidol.Instrumentalist" autowire="byType">

    <property name="song" value="Jingle Bells" />

    <property name="instrument" ref="saxophone" />


    As illustrated here, mixing automatic and explicit wiring is also a great way to deal

    with ambiguous autowiring that may occur when autowiring using byType. There

    may be several beans in the Spring context that implement Instrument. To keep

    Spring from throwing an exception due to the ambiguity of several Instruments

    to choose from, we can explicitly wire the instrument property, effectively overriding


    See also response to the question autowire byName and byType


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    scores100 challenge 3 67
    wordsWithoutList  challenge 24 61
    mapBully challenge 6 53
    Unable to start eclipse ? 17 48
    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now