aspose file tools
The moose likes Spring and the fly likes How to autowire byName using interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to autowire byName using interface" Watch "How to autowire byName using interface" New topic

How to autowire byName using interface

Om Prakash Bijawat

Joined: Feb 01, 2013
Posts: 10
Hi ,

This is my interface:

These are my two implementation classes :

And this is my service class :

my Main method :

In my master-quiz.xml file I have written :

<bean id = "springQuizMaster" class =""></bean>
<bean id = "strutsQuizMaster" class = ""></bean>
<bean id = "quizMasterService" class = "" init-method = "init" destroy-method = "destroy" autowire="byName">

When I use :

<constructor-arg ref="springQuizMaster"/> instead of autowire attribute it runs perfect

but while using autowiring it fails.
Can anyone help me out?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31680

You can't autowire here without more information because there are two beans that go with that constructor. Spring has no way to know which bean you want injected. That's why it works when you use the constructor.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Have you tried LearnNowOnline?
subject: How to autowire byName using interface