Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/po/IdCard

  • Post author:
  • Post category:java





报错内容:

Unsatisfied dependency expressed through field ‘personDao’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘personDao’ defined in file [C:\Users\huanshao\workspace\ch7\bin\com\dao\PersonDao.class]: Cannot resolve reference to bean ‘sqlSessionFactory’ while setting bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource




[applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/po/IdCard (wrong name: com/po/Idcard)




原因:

可能是变量名这种小错误!!比如看下图:


持久层文件


在这里插入图片描述


映射文件


在这里插入图片描述



解决办法:


将映射文件resultType值:IdCard改为Idcard



版权声明:本文为weixin_44943631原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。