springMVC整合JDBC出现的错误,后台测试通过,但页面访问时不成功,提示注入失败!

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'websiteController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'menuDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'menuDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:903)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'websiteController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'menuDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'menuDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:903)
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:903)

4个回答

用的是哪个注解@Resource 默认by name @Inject&@Autowired default by type;看你报错是by name 找websiteController 和menuDao没找到,注解是不是没加name值,或者注解没加

out_of_it_farmer
弗里德姆 回复wsrf_CSDN: ok
2 年多之前 回复
wsrf_CSDN
wsrf_csdn 已经解决了,就是在web.xml里面没有配置监听器,从而导致找不到XML配置文件所致
2 年多之前 回复
out_of_it_farmer
弗里德姆 问题详细一点~~
2 年多之前 回复

异常提示找不到数据源声明导致依赖注入失败。你说的后台测试是什么意思?服务器跑起来了吗?

wsrf_CSDN
wsrf_csdn 就是main函数能够正常运行的,页面访问的话,就出现注入失败了![![图片说明](http://img.ask.csdn.net/upload/201710/03/1507012181_967.png)片说明](http://img.ask.csdn.net/upload/201710/03/1507012161_879257.png)![图片说明](http://img.ask.csdn.net/upload/201710/03/1507012033_389330.png)
2 年多之前 回复

就是main函数能够正常运行的,页面访问的话,就出现注入失败了![图片说明](https://img-ask.csdn.net/upload/201710/03/1507012181_967.png)图片说明
图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐