-1

Stacktrace:

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.vliv.dao.MySqlLogDao] is defined: expected single matching bean but found 2: mySqlLogDaoImpl,mySqlLogDao

Java code:

public interface MysqlDao {
    public void regstr();
}

@Repository
@Transactional
public class MysqlDaoImpl { 
    public void regstr() {}
}

@Controller
public class Brand {
    @Autowired
    MySqlDao mySqlDao;//gives exception
}
LaurentG
  • 11,128
  • 9
  • 51
  • 66
ritesh
  • 13
  • 1
  • 2
  • What is your question? Also post your application context file – Reimeus Oct 06 '13 at 19:56
  • Please make an effort into describing your problem in clear english before copy/paste of an Exception. And please use formatting capabilies of SO to enclose code and exception into a block of code for better reading. – Raphael Jolivet Oct 06 '13 at 19:57

1 Answers1

1

The exception is pretty clear. There exist 2 beans in your application context which implement the interface you are wiring into your controller.

Spring doesn't know which one you actually want so it's throwing an exception. Try using the @Qualifier annotation to indicate which implementation you actually want:

See the api documentation here:

http://docs.spring.io/spring/docs/3.1.4.RELEASE/javadoc-api/org/springframework/beans/factory/annotation/Qualifier.html

Aurand
  • 5,487
  • 1
  • 25
  • 35