启动项目spring报错 某一个类自动转换对象bean失败

 直接上报错

ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeCtrl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cpic.caf.template.home.service.impl.TestUserService com.cpic.caf.template.home.controller.HomeCtrl.testUserservice; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testUserService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cpic.caf.template.home.mybatiesDao.TestUserDao com.cpic.caf.template.home.service.impl.TestUserService.dao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cpic.caf.template.home.mybatiesDao.TestUserDao] 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)}

我找了很多方式,最后原因是由于这个项目我刚接手,原因是spring默认没有打开mybatis的配置文件 所以报错

<import resource="classpath*:mybaties/MybatiesConf.xml"/> 加入这段即可

猜你喜欢

转载自blog.csdn.net/qq_37612068/article/details/83087665
今日推荐