Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Mixing auto and  explicit wiring

Posted on 2011-05-04
1
Medium Priority
?
245 Views
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.
0
Comment
Question by:gudii9
1 Comment
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 35695245

This is a good explanation from
http://translated.by/you/spring-in-action-second-edition-part-1-core-spring/original/?page=23

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

</bean>

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

autowiring

See also response to the question autowire byName and byType
 



0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

810 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