zoukankan      html  css  js  c++  java
  • idea报错:Invalid bound statement (not found)

    在配置MyBatis接口映射的Mapper.xml时,提示Invalid bound statement (not found)异常,就算是接口和xml名字相同,路径相同也无法找到,在网上找到了几种解方案。

    • idea默认不扫描src/main/java 下的xml文件,想要放在同一目录下,需要在pom.xml中配置扫描java目录下的xml即可,在build节点下添加:

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
      
    • 在resources目录下创建相同的包,运行不可以,需要在spring-mybatis.xml中配置mybatis扫描的地方(这一步不用也行。。):

        <mybatis:scan base-package="com.yl.note.mapper"></mybatis:scan>
      

      另外,在sqlSessionFactory的Bean中添加:

        <property name="mapperLocations" value="classpath*:com.yl.note.mapper/**/*.xml"/>
      

    可用。

    • 在mybatis的配置文件中添加:

        <mappers>
      
            <!--扫描xml-->
            <mapper resource="com/yl/note/mapper/UserMapper.xml"/>
            <!--扫描接口-->
            <package name="com.yl.note.mapper"/>
      
        </mappers>
      

    上述三种任选其一即可,其中第三种有待验证。


    2017-11-13

    在项目编译的时候发现无法引入properties文件,在resource中引入<include>**/*.properties</include>就行了。。。真是日了狗

    		<build>
    			<resources>
    				<resource>
    					<directory>src/main/java</directory>
    					<includes>
    						<include>**/*.xml</include>
    					</includes>
    				</resource>
    				<resource>
    					<directory>src/main/resources</directory>
    					<includes>
    						<include>**/*.xml</include>
    						<include>**/*.properties</include>//加入此条目
    					</includes>
    				</resource>
    			</resources>
    		</build>
  • 相关阅读:
    OSCP Learning Notes Buffer Overflows(3)
    OSCP Learning Notes Buffer Overflows(5)
    OSCP Learning Notes Exploit(3)
    OSCP Learning Notes Exploit(4)
    OSCP Learning Notes Exploit(1)
    OSCP Learning Notes Netcat
    OSCP Learning Notes Buffer Overflows(4)
    OSCP Learning Notes Buffer Overflows(1)
    OSCP Learning Notes Exploit(2)
    C++格式化输出 Learner
  • 原文地址:https://www.cnblogs.com/esileme/p/7716616.html
Copyright © 2011-2022 走看看