Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:27:23+00:00 2026-06-05T23:27:23+00:00

I’m using Spring 3.0 with a genericDAO. I have this: public interface GenericDAO<T, ID

  • 0

I’m using Spring 3.0 with a genericDAO. I have this:

public interface GenericDAO<T, ID extends Serializable>
...
@Repository("genericDAO")
public class GenericDAOImpl<T, ID extends Serializable> implements GenericDAO<T, ID> {
...
public interface A extends GenericDAO<Turno, Long> {
...
public interface B extends GenericDAO<TipoTurno, Long> {
...
@Repository("A")
public class AImpl extends GenericDAOImpl<TipoTurno, Long>  implements A{
...
@Repository("B")
public class BImpl extends GenericDAOImpl<TipoTurno, Long>  implements B{

But when I try to get them injected as follow:

@Autowired
A a;

I get:

expected single matching bean but found 3: [genericDAOImpl, A, B]

I can’t understand why. I also tried to do it with

@Resource(name="A")

and even

@Resource(type=A.class)

I also tried using @Qualifier but I always get the same exceptions, it looks like Spring is always looking for GenericDao and not the specific class.

but it’s still not working. And I can’t understand why.

Any suggestions?

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:27:25+00:00Added an answer on June 5, 2026 at 11:27 pm

    I reproduced your exact error message and then fixed it. Here is exactly the source code I used, minus package names. I recommend copying it, running it and diffing it with yours. One difference I noticed is that as written in the question, AImpl does not compile. It implements both GenericDAOImpl and GenericDAO. I changed the first generic parameter to Turno, to make it compile. I assume this was a typo. I reproduced exactly your error when I initially set all the fields to @Autowired. Then I added @Qualifier(“genericDAO”) and it wired all three successfully.

    public interface GenericDAO<T, ID extends Serializable> {}
    ...
    @Repository("genericDAO")
    public class GenericDAOImpl<T, ID extends Serializable> implements GenericDAO<T, ID> {}
    ...
    public interface A extends GenericDAO<Turno, Long> {}
    ...
    public interface B extends GenericDAO<TipoTurno, Long> {}
    ...
    @Repository("A")
    public class AImpl extends GenericDAOImpl<Turno, Long> implements A {}
    ...
    @Repository("B")
    public class BImpl extends GenericDAOImpl<TipoTurno, Long>  implements B {}
    ...
    public class TipoTurno {}
    ...
    public class Turno {}
    ...
    @Component
    public class Thingy {
        @Autowired
        private A a;
    
        @Autowired
        private B b;
    
        @Autowired
        @Qualifier(value="genericDAO")
        private GenericDAO genericDao;
    }
    ...
    public class Main {
        public static void main(String[] args) {
            ApplicationContext context = new ClassPathXmlApplicationContext("genericdao.xml");
            context.getBean(Thingy.class);
        }
    }
    ...
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <context:annotation-config/>
        <context:component-scan base-package="genericdao"/>
    </beans>
    

    Note that the actual error message is longer than the one you provided. It is important to read the whole thing looking for causes. Spring loves exception stack traces with 5, even 10 levels of causes. Here is the relevant substring of the message I get:

    Could not autowire field: genericdao.GenericDAO genericdao.Thingy.genericDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [genericdao.GenericDAO] is defined: expected single matching bean but found 3: [A, B, genericDAO]

    It indicates that the field that was not being autowired was Thingy.genericDao, not Thingy.a. I strongly suspect this is the case for your error as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.