zoukankan      html  css  js  c++  java
  • 在Maven工程下Spring和Mybatis整合出现Invalid bound statement (not found):错误

    工程下mapper.xml和mapper.java都存在切名称都对应

    我习惯将mapper的xml和java都放在中的同一目录下

    网上看了各种办法均失败

    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <!DOCTYPE mapper
    3 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    5 <mapper namespace="mapper">
    6     <select id="findUserByIdMapper" parameterType="int" resultType="ssm.po.User">
    7         select *from user where id=#{id}
    8     </select>
    9 </mapper>

    这是改之前的代码,问题出在<mapper namespace="mapper"> 原来mapper代理开发的xml文件中namespace不能乱写,必须用对应mapper.java的全路径,也就是Ctrl要点的进去.

     因为用的是Maven构建,在pom.xml的<build></build>标签中添加如下代码即可

                    <resources> 
                <resource> 
                    <directory>src/main/java</directory> 
                    <includes> 
                        <include>**/*.properties</include> 
                        <include>**/*.xml</include> 
                    </includes> 
                    <filtering>false</filtering> 
                </resource> 
                <resource> 
                    <directory>src/main/resources</directory> 
                    <includes> 
                        <include>**/*.properties</include> 
                        <include>**/*.xml</include> 
                    </includes> 
                    <filtering>false</filtering> 
                </resource> 
            </resources>             

    问题解决!

  • 相关阅读:
    AWK
    ftp自动上传下载文件脚本
    tostring格式化输出
    C#时间处理--DateTime和TimeSpan
    C#正则表达式语法规则详解
    C#常用的正则表达式
    C#字符串截取
    FTP操作
    [BZOJ2947]促销(Splay)
    [BZOJ1208]宠物收养所(Splay)
  • 原文地址:https://www.cnblogs.com/haoxiansen/p/8847710.html
Copyright © 2011-2022 走看看