zoukankan      html  css  js  c++  java
  • maven工程下整合spring+mybatis报Mapped Statements collection does not contain value for spring-mybatis-user-get错误

    在整合spring+mybatis报了下面的错误:

    Mapped Statements collection does not contain value for spring-mybatis-user-get,找了很久也没找到正确的方法。经过排查,发现mybatis的mapper.xml

    位于和src/main/java一样的包下,如下图

    User.xml文件位于spring.mybatis.user下,在src/main/java和src/main/resources下都有这个路径的包,而我在spring中mybatis的配置如下

    <bean id="sqlSessionFactory"
              class="org.mybatis.spring.SqlSessionFactoryBean"
              p:dataSource-ref="dataSource"
              p:configLocation="classpath:myBatisConfig.xml"
              p:mapperLocations="classpath:spring/mybatis/user/**/*.xml"/> 

    因此,我怀疑扫描mapperxml文件时,在src/main/java和src/main/resources下有一样的包时,会以src/main/java中的

    为准,因此,我将src/main/resources下的包改成spring.mybatis.iuser,同时将spring配置的路径改成classpath:spring/mybatis/iuser/**/*.xml,即

    <bean id="sqlSessionFactory"
              class="org.mybatis.spring.SqlSessionFactoryBean"
              p:dataSource-ref="dataSource"
              p:configLocation="classpath:myBatisConfig.xml"
              p:mapperLocations="classpath:spring/mybatis/iuser/**/*.xml"/> 

    再次运行单元测试,通过!困扰了一天的问题终于解决了。

  • 相关阅读:
    使用PrintDocument进行打印
    【转】封装原生JS实现Ajax
    休眠到指定时分秒
    [原创]vscode初体验
    反编译网站
    命令行工具aspnet_regiis.exe实现加密和解密web.config
    Sqlserver内置函数实现MD5
    [转]如何循序渐进向dotnet架构师发展
    [转]高级系统架构师培训笔记
    理解RESTful
  • 原文地址:https://www.cnblogs.com/cdblogs/p/7897092.html
Copyright © 2011-2022 走看看