首页 新闻 会员 周边 捐助

请教:springmvc+mybatis启动报错,报错信息如下:

0
悬赏园豆:5 [已关闭问题] 关闭于 2016-10-08 11:01

2016-08-24 16:02:13 -1946 [localhost-startStop-1] WARN    - Invocation of destroy method 'close' failed on bean with name 'sqlSessionTemplate': java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession
2016-08-24 16:02:13 -1948 [localhost-startStop-1] INFO    - {dataSource-1} closed
2016-08-24 16:02:13 -1949 [localhost-startStop-1] ERROR   - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usysparamServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.fh.dao.UsysparamMapper com.fh.service.impl.UsysparamServiceImpl.usysparamMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.fh.dao.UsysparamMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.fh.dao.UsysparamMapper com.fh.service.impl.UsysparamServiceImpl.usysparamMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.fh.dao.UsysparamMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 22 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.fh.dao.UsysparamMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    ... 24 more

雪剑残云的主页 雪剑残云 | 菜鸟二级 | 园豆:217
提问于:2016-08-24 16:38
< >
分享
所有回答(2)
0

NoSuchBeanDefinitionException: No qualifying bean of type [com.fh.dao.UsysparamMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: 

有多个类声称自己是UsysparamMapper子类,Spring表示不会掷骰子?

之奇一昂 | 园豆:1421 (小虾三级) | 2016-08-24 16:44

您好,麻烦您再说清楚点吗?具体怎么解决?万分感谢!!!

支持(0) 反对(0) 雪剑残云 | 园豆:217 (菜鸟二级) | 2016-08-24 16:47

@雪剑残云: 已经很明白了啊,有至少两个类说自己是com.fh.dao.UsysparamMapper的子类,找出来干掉一个就可以了。我觉得很大的可能性是你复制Mapper 的时候注解没有修改,从而导致本来两个不同的类由于注解成了同一个类的实现。

支持(0) 反对(0) 之奇一昂 | 园豆:1421 (小虾三级) | 2016-08-25 08:20
0

你的com.fh.dao.UsysparamMapper接口的实现类有多个

spring在注入实现类的时候不知道注入哪一个

你干掉一个就可以了

 

sakuraph | 园豆:224 (菜鸟二级) | 2016-08-24 17:03

没有啊,实现类就一个啊,怎么会有多个呐?

支持(0) 反对(0) 雪剑残云 | 园豆:217 (菜鸟二级) | 2016-08-24 17:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册