wood burning stoves 2.0*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to autowire byName using interface" Watch "How to autowire byName using interface" New topic
Author

How to autowire byName using interface

Om Prakash Bijawat
Greenhorn

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 ="com.services.SpringQuizMaster"></bean>
<bean id = "strutsQuizMaster" class = "com.services.StrutsQuizMaster"></bean>
<bean id = "quizMasterService" class = "com.services.QuizMasterService" 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?
Thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

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.

[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to autowire byName using interface