SSM框架整合错误:Could not autowire field

debug信息:

spring整合mybatis错误:Could not autowire field: com.zy.ssm.service.BookService com.zy.ssm.contr...

分析:
可以清晰的看出是Could not autowire field错误,错误原因是:com.zy.ssm.service.BookService这个类无法自动装配,位于
Error creating bean with name 'bookService'此处

无法自动装配一般是spring配置文件未配置扫描,查看spring-dao.xml文件:

解决1:

发现未扫描impl包,所以加上<context:component-scan base-package="your package location" />对应的包地址就行了,注意替换成你自己的包地址

 解决2:

检查@controller,@Service等注释写了没

问题2:

解决:这两处不要同名

原文地址:https://www.cnblogs.com/yangmie/p/13277107.html