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


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

目录
相关文章
|
6月前
|
架构师 Java 数据库连接
成功解决:com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl.
这篇文章提供了解决Spring整合MyBatis时报错的配置方法,包括使用Spring的上下文属性占位符加载数据库配置文件`db.properties`,并在Spring配置文件中声明并配置数据源`DruidDataSource`。
|
6月前
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.
149 0
|
9月前
|
Java
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
144 0
|
9月前
|
Java 数据库连接 数据库
Mybatis JDBC No enum constant org.apache.ibatis.type.JdbcType.TEXT异常处理
Mybatis JDBC No enum constant org.apache.ibatis.type.JdbcType.TEXT异常处理
409 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原因总结
1132 0
【SSM】nested exception is org.apache.ibatis.binding.BindingException: Invalid boun原因总结
|
druid Java
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
844 0
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
|
Java 微服务 Spring
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
511 0
|
关系型数据库 MySQL
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url
3231 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
438 0
|
Java 数据库连接 Spring
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ XXX‘
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ XXX‘
318 0