解决 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);
    }
    
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



猜您在找 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'xxx 'available Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} springboot启动报错:Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zxkj.lockserver.dao.CompanyDao' available: expected at least 1 bean which qua org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException 错误之Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined 多个@bean无法通过@resource注入对应的bean(org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found )
 
粤ICP备18138465号  © 2018-2026 CODEPRJ.COM