log N
log N

Reputation: 945

Autowiring byName or byType or constructor?

1)In Spring which autowiring in preferred?I am a beginner in learning springs so am not getting which ones to use frequently?Is it that the different types of autowiring have their own advantages and disadvantages?If yes then what?

2)From Springs in action

eg:

<bean id="saxophone"
 class="com.springinaction.springidol.Saxophone"
 primary="true" />

And all the others their primary is set false.So i can only use this bean for autowiring.So what if i need other beans to autowire which are of the same Instrument type since saxophone is of the Instrument type and that since saxophone is declared primary then how will others be preferred depending upon situations?

Upvotes: 0

Views: 687

Answers (1)

user2550754
user2550754

Reputation: 905

No autowiring have advantages or disadvantages. It solely depends upon you, which one to use or your project specification and architecture.

And for your particular example, you have to use byName autowiring.

Upvotes: 1

Related Questions