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
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29259
    
140

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
 
Similar Threads
autowiring byName in spring
Problem calling destroy method
Need help on Spring - Quartz Job deployment in Jboss server
method injection problem
Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationExcep