【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;
    }


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

目录
相关文章
|
2月前
|
Java
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
47 0
|
2月前
|
Java 数据库连接 数据库
Mybatis JDBC No enum constant org.apache.ibatis.type.JdbcType.TEXT异常处理
Mybatis JDBC No enum constant org.apache.ibatis.type.JdbcType.TEXT异常处理
136 0
|
2月前
|
前端开发 Java 数据库连接
若依 mybatis报错nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘XXX‘ 错误
若依 mybatis报错nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘XXX‘ 错误
33 0
|
2月前
No qualifying bean of type [com.XX.mapper.SysNameMapper ] found for dependency
No qualifying bean of type [com.XX.mapper.SysNameMapper ] found for dependency
80 0
|
9月前
|
Java 微服务 Spring
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
70 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:
745 0
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
|
8月前
org.apache.ibatis.builder.BuilderException: An invalid property ‘jdbcType ‘ was found in mapping
org.apache.ibatis.builder.BuilderException: An invalid property ‘jdbcType ‘ was found in mapping
|
12月前
No qualifying bean of type ‘org.springframework.boot.autoconfigure.http.HttpMessageConverters‘ avail
No qualifying bean of type ‘org.springframework.boot.autoconfigure.http.HttpMessageConverters‘ avail
118 1
|
关系型数据库 MySQL
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
2830 0
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
|
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
299 0