错误描述如下:
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>