【ERROR】No qualifying bean of type ‘com.alibaba.druid.pool.DruidDataSource‘ available

简介: 【ERROR】No qualifying bean of type ‘com.alibaba.druid.pool.DruidDataSource‘ available

ssm框架整合一直报错:


Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.alibaba.druid.pool.DruidDataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}


最后排查发现原因,配置MybatisConfig时候,依赖注入那里一直写的是DruidDataSource dataSource:


@Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean(DruidDataSource dataSource){
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        sqlSessionFactoryBean.setDataSource(dataSource);
        sqlSessionFactoryBean.setTypeAliasesPackage("com.zcongfly.pojo");
        return sqlSessionFactoryBean;
    }


改成DruidDataSource dataSource就能跑了:


@Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource){
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        sqlSessionFactoryBean.setDataSource(dataSource);
        sqlSessionFactoryBean.setTypeAliasesPackage("com.zcongfly.pojo");
        return sqlSessionFactoryBean;
    }


我他喵,好想扇死自己。。。

目录
相关文章
|
5月前
|
架构师 Java 数据库连接
成功解决:com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl.
这篇文章提供了解决Spring整合MyBatis时报错的配置方法,包括使用Spring的上下文属性占位符加载数据库配置文件`db.properties`,并在Spring配置文件中声明并配置数据源`DruidDataSource`。
|
5月前
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
119 0
|
8月前
|
Java
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
120 0
|
XML SQL Java
【SSM】nested exception is org.apache.ibatis.binding.BindingException: Invalid boun原因总结
【SSM】nested exception is org.apache.ibatis.binding.BindingException: Invalid boun原因总结
1112 0
【SSM】nested exception is org.apache.ibatis.binding.BindingException: Invalid boun原因总结
|
Java 微服务 Spring
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
388 0
|
druid Java
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
832 0
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
|
关系型数据库 MySQL
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
3206 0
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
No qualifying bean of type ‘org.springframework.boot.autoconfigure.http.HttpMessageConverters‘ avail
No qualifying bean of type ‘org.springframework.boot.autoconfigure.http.HttpMessageConverters‘ avail
166 1
|
druid
java.lang.IllegalStateException: Error processing condition on com.alibaba.druid.spring.boot.autocon
java.lang.IllegalStateException: Error processing condition on com.alibaba.druid.spring.boot.autocon
408 0
|
Java 数据库连接 mybatis
项目依赖问题导致No qualifying bean of type 'org.apache.ibatis.session.SqlSessionFactory' available: more tha...
项目依赖问题导致No qualifying bean of type 'org.apache.ibatis.session.SqlSessionFactory' available: more tha...
373 0