解决 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的问题...

Bertha 。 2021-09-20 10:26 608阅读 0赞

  具体错误如下:

  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.thinkplatform.dao.UserLogDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency    annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

  经过排查发现在UserLogDaoImpl的实现类前面加个@Repository 就可以了

  1. package com.thinkplatform.dao.impl;
  2. import java.io.Serializable;
  3. import org.apache.ibatis.session.SqlSessionFactory;
  4. import org.mybatis.spring.support.SqlSessionDaoSupport;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Repository;
  7. import com.thinkplatform.dao.UserLogDao;
  8. import com.thinkplatform.entity.UserLog;
  9. @Repository
  10. public class UserLogDaoImpl extends SqlSessionDaoSupport implements UserLogDao{
  11. public UserLogDaoImpl() {
  12. this.ns = "UserLogMapper";
  13. }
  14. @Autowired
  15. public void setSqlSessionfactory(SqlSessionFactory sqlSessionFactory) {
  16. super.setSqlSessionFactory(sqlSessionFactory);
  17. }
  18. //命名空间
  19. private String ns;
  20. public String getNs(){
  21. return this.ns;
  22. }
  23. public void insert(UserLog userLog) {
  24. this.getSqlSession().insert(ns+".insert",userLog);
  25. }
  26. public void update(UserLog userLog) {
  27. this.getSqlSession().update(ns+".update",userLog);
  28. }
  29. public String get(Serializable id) {
  30. return this.getSqlSession().selectOne(ns+".get",id);
  31. }
  32. }

转载于:https://www.cnblogs.com/shaosks/p/9087048.html

发表评论

表情:
评论列表 (有 0 条评论,608人围观)

还没有评论,来说两句吧...

相关阅读