Could not autowire. No beans of 'UserDao' type found. 错误个人见解

Could not autowire. No beans of 'UserDao' type found. 

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

如果说出现这个问题得时候,向服务断发送请求得时候并没有报错,这Idea自身得毛病,不用管!有得时候就怕是其他得错误,然而归咎于 Could not autowire. No beans of 'UserDao' type found. 它,那就很头痛了,

比如:

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

现在启动并没有报错,感觉一切正常,然而访问的时候

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

报错了?????????

就会误以为是 @Autowired注解引起的

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

这两者之间的不匹配导致的!

再出现一个异常

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

这是因为在mapper.xml文件里面配置的时候 <resultMap></resultMap>标签里面的

<id     column="id"     property="iD"   jdbcType="INTEGER" /> property属性与实体类里面的id名称不对应所导致的!!

也就是说,当遇到这个问题的时候,访问是能够正常,如果出现异常,就不纠结是这个问题,也许是其他地方的原因!!

也许例子不怎么恰当!广收大量的异常!清者自清,浊者自浊!

如果说你用这个注解出现这个问题,那就换一个注解  @Resource  位于  import javax.annotation.Resource; 包下 

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

就不会出现这个提醒,启动也不会报错,访问也将正常

Could not autowire. No beans of 'UserDao' type found. 错误个人见解

文章转载于:https://blog.csdn.net/qq_38425662/article/details/79805907