Spring异常:Injection of autowired dependencies failed
时间:2017-12-27
异常:Injection of autowired dependencies failed
情景:
本项目是Spring+Struts2+Mybatis框架,我在生成几个Mapper后,觉得多余又给删除了,结果删除之后,部署项目就本地服务器就一直报错,最根本的异常是Injection of autowired dependencies failed,我反复检查,所有的Mapper已经还原到项目尚未更变时的版本,但依旧无法部署。
原因:
1.server的location部署错误,应当存放在worspace之下。
2.当对generatorConfig.xml右键“Generate Mybatis”时,应将生成过mapper的<table>标签给注释掉,否则会在服务器后台生成多余的mapper文件,
即便删除eclipse里的内容也还是会存在,这样一来,原先有依赖注入的mapper都会导致项目部署出错。
解决:
将server的location修正为worspace。
删除webapps下的项目,删除server,重新创建一个server部署一次就OK了。
重新生成dbo下的model和mapper,并注释掉已经生成好mapper的<table>标签。