解决Unsatisfied dependency expressed through field ‘jdbcTemplate‘;问题~

简介: 解决Unsatisfied dependency expressed through field ‘jdbcTemplate‘;问题~

错误描述如下:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean

错误原因中的下述代码是重点,大概意思为,没有匹配到对应的bean,而这个bean的类型为'org.springframework.jdbc.core.JdbcTemplate'

Error creating bean with name 'bookDaoImpl': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.jdbc.core.JdbcTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

因此解决办法为,在对应的XML文件中创建对应的bean对象,如下所示:

<bean class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"></property>
</bean>
相关文章
|
SQL 安全 Java
SpringData JPA(2)
SpringData JPA(2)
128 1
|
4月前
Unsatisfied dependency expressed through field 'restTemplate';
Unsatisfied dependency expressed through field 'restTemplate';
90 0
|
7月前
Unsatisfied dependency expressed through field ‘baseMapper‘
Unsatisfied dependency expressed through field ‘baseMapper‘
51 2
|
Java Linux 程序员
记录:Unsatisfied dependency expressed through field 'XxxService'...【亲测有效】
记录:Unsatisfied dependency expressed through field 'XxxService'...【亲测有效】
1604 1
|
7月前
No qualifying bean of type [com.XX.mapper.SysNameMapper ] found for dependency
No qualifying bean of type [com.XX.mapper.SysNameMapper ] found for dependency
99 0
|
Java 容器 Spring
No qualifying bean of type或Unsatisfied dependency expressed through field ‘XXXService‘或@Autowired 注入
No qualifying bean of type或Unsatisfied dependency expressed through field ‘XXXService‘或@Autowired 注入
216 0
Unsatisfied dependency expressed through field ‘passwordEncoder
Unsatisfied dependency expressed through field ‘passwordEncoder
106 0
Unsatisfied dependency expressed through field ‘passwordEncoder
|
Java 数据库连接 Spring
spring整合 mybatis时 SqlSessionFactoryBean的一个小报错:Bean named ‘sqlSessionFactory‘ is expected to be of ty
spring整合 mybatis时 SqlSessionFactoryBean的一个小报错:Bean named ‘sqlSessionFactory‘ is expected to be of ty
428 0
|
NoSQL Java Redis
Unsatisfied dependency expressed through field /Injection of autowired dependencies failed 解决方法
根据报错的关键字,大底的意思就是依赖方面的问题。
344 0
Error creating bean with name ‘userServiceImpl‘: Unsatisfied dependency expressed through field ‘bas
Error creating bean with name ‘userServiceImpl‘: Unsatisfied dependency expressed through field ‘bas
435 0