zoukankan      html  css  js  c++  java
  • Spring+Mybatis整合报错Mapped Statements collection does not contain value原因之一

     报错如下:

    ### Error updating database.  Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.xxx.entity.UserMapper.insert
    ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.xxx.entity.UserMapper.insert
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
        at com.sun.proxy.$Proxy10.insert(Unknown Source)
        at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)

     可能的原因是:mapperLocations的value值classpath缺少了*号

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
            <property name="mapperLocations" value="classpath:com/xxx/*/mapper/*.xml" />
        </bean>

    修改如下:

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
            <property name="mapperLocations" value="classpath*:com/xxx/*/mapper/*.xml" />
        </bean>
  • 相关阅读:
    12 python json&pickle&shelve模块
    11 python shutil 模块
    10 python os&sys 模块
    9 random模块
    8 python time$datetime
    7 python 模块间相互导入
    6 unit3-文件操作&函数 review
    3 Python 函数介绍
    hibernate课程 初探单表映射2-6 session详解(下)
    hibernate课程 初探单表映射2-5 session详解(上)
  • 原文地址:https://www.cnblogs.com/lyxy/p/5164811.html
Copyright © 2011-2022 走看看