zoukankan      html  css  js  c++  java
  • 我的Java历程_spring+springmvc+mybatils整合问题

    作为一个初学框架的菜鸟,有时候遇到异常时真的不好判断问题的出处,因为一般框架不就是导jar包,配置文件嘛,对于一个新手来说要看懂错误出现的含义韩式有些难的,lz昨天整合spring+mybatils时就出现了几个小错误,在此分享一下:

    异常一:

    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]
    Offending resource: class path resource [applicationContext.xml]......

    百度一番,答案啥样的都有,有说是缺少了三个jar包,但是lz下载jar包加进去之后仍然是不行的,仔细检查发现,spring我用的是3.2.5,而我的头文件是3.2这就是问题的根源所在,把头文件改正确了。全部改为了3.2.5版本。本以为问题就此解决时,下一个问题出现,测试发现另一个异常。

    异常二:

    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'..............

    这就是只改完头文件后所出现的问题,一同google,问题之所在找到,加上本人也是有所猜测,所以果断的吧spring的jar包换成3.2,applicationContext.xml的配置文件还原成当初3.2版本的,再测试,OK。

    异常三:

    rg.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
    ### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.wx.blog.user.entity.WebUserMapper.add
    ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.wx.blog.user.entity.WebUserMapper.add
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible...........................

    这就是spring基本没什么问题了,然后mybatil的的问题,排查,lz有个习惯就是一般都是先看异常信息,看自己是否见过这个异常的,但是一番检查,没看懂,很难受,然后调试,自己检查路径发现com.wx.blog.user.entity.WebUserMapper.add这个路径定位到实体类的包里面去了,这很尴尬,改正,mybatils名称空间指向自己的持久层接口,OK.

    总结:使用框架配置文件时。一定要注意环境的版本,还有就是细心加细心,或许一个小小的手抖,就需要用一两天的时间或者更久的时间去排查,当然我也需要多出问题,不然怎么能够学会排查问题呢,-_-,但是该细心还是得细心!!!!

  • 相关阅读:
    linux转换win下乱码txt命令
    linux下vi命令大全详细版本
    ubuntu系统如何安装adb调试环境
    LeetCode136---只出现一次的数字
    微信发朋友圈--用例设计(转)
    微服务
    LeetCode1---两数之和
    python输出
    爬楼梯,N级楼梯有多少种走法?
    list数组排序---stream
  • 原文地址:https://www.cnblogs.com/Eternally-dream/p/6728232.html
Copyright © 2011-2022 走看看