ssm中的常见异常与解决方法

Error creating bean with name ‘sqlSessionFactory’ XXXXX

  1. 具体异常描述:
    Error creating bean with name ‘sqlSessionFactory’ defined in URL [file:/D:/Program%20Files/IdeaProject/ssm_plus/target/ssmdemo5/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException:
    Failed to parse mapping resource: ‘file [D:\Program Files\IdeaProject\ssm_plus\target\ssmdemo5\WEB-INF\classes\mapper\UserMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘com.ssm.bean.user’.
  2. 异常分析:
    查看整个异常信息,可以发现最重要的信息为找不到’com.ssm.bean.user’。导致生成bean sqlSessionFactory失败。出现原因:由于mapper.xml文件等配置文件时复制他人的,导致很多包名都是错的
  3. 解决方法:在idea中打开全局搜索,对第一种异常,搜索"com.ssm.bean.use",将所有的包名都更改为自己设置的包名;

nested exception is java.lang.NoClassDefFoundError: javax/xml/registry/infomodel/User

  1. 具体异常描述:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in URL [file:/D:/Program%20Files/IdeaProject/ssm_plus/target/ssmdemo5/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/registry/infomodel/User
  2. 异常分析:原因为找不到类javax/xml/registry/infomodel/Use,原因往往是在导入User包时导入错误的包,在service层以及controller层中导入的是javax/xml/registry/infomodel/User而不是自己编写的User实体类。
  3. 解决方法:搜索所有javax.xml.registry.infomodel.User,更改为自己编写的User实体类
    对以上两种异常,都可以先查看完整的异常信息,然后在idea中使用全局搜索查找异常信息中的关键部分,即可很快的找到错误原因。

你可能感兴趣的:(ssm中的常见异常与解决方法)