zoukankan      html  css  js  c++  java
  • 解决 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的问题

      具体错误如下:

      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 就可以了

    package com.thinkplatform.dao.impl;
    import java.io.Serializable;
    
    import org.apache.ibatis.session.SqlSessionFactory;
    import org.mybatis.spring.support.SqlSessionDaoSupport;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;
    import com.thinkplatform.dao.UserLogDao;
    import com.thinkplatform.entity.UserLog;
    
    
    @Repository 
    public class UserLogDaoImpl extends SqlSessionDaoSupport implements UserLogDao{
    
        public UserLogDaoImpl() {
            this.ns = "UserLogMapper";
        }
        @Autowired
        public void setSqlSessionfactory(SqlSessionFactory sqlSessionFactory) {
            super.setSqlSessionFactory(sqlSessionFactory);
        }
        
        //命名空间
        private String ns;
        
        
        public String getNs(){
            return this.ns;
        }
        
        
        public void insert(UserLog userLog) {
            this.getSqlSession().insert(ns+".insert",userLog);
        }
        
        public void update(UserLog userLog) {
            this.getSqlSession().update(ns+".update",userLog);
        }
    
        
        public String get(Serializable id) {
            return this.getSqlSession().selectOne(ns+".get",id);
        }
        
    }
  • 相关阅读:
    nginx端口重定向及反向代理
    Linux Crontab实现定时备份和删除Docker中的Mysql数据库
    Linux创建定时任务
    Docker可视化管理工具Portainer的安装配置及使用
    Centos磁盘扩容-免重启
    使用CSS让网页自适配手机端
    Centos7 安装FTP
    Centos7 部署的Redis无法远程访问
    移动端调试
    select2初始化默认选中值(多选)
  • 原文地址:https://www.cnblogs.com/shaosks/p/9087048.html
Copyright © 2011-2022 走看看