码迷,mamicode.com
首页 > 编程语言 > 详细

原创: spring整合mybatis配置,包括错误调试改整,明天用半天时间来整理

时间:2020-03-06 22:23:27      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:路径   repeat   ota   intellij   edm   star   span   config   cache   

错误提示:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.ibaiqi.gather.dao.RecruitGatherDao.listRecruitGathers
 
1:applicationContent.xml配置(整合 mybatis
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc.xsd
                        http://www.springframework.org/schema/tx
                        http://www.springframework.org/schema/tx/spring-tx.xsd
                        http://mybatis.org/schema/mybatis-spring
                        http://mybatis.org/schema/mybatis-spring.xsd ">
    <!--开启扫描注解-->
    <mvc:annotation-driven/>
    <!---->
    <context:component-scan base-package="org.ibaiqi.gather"></context:component-scan>
    <!--开始整合  mybatis-->
        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location" value="jdbc.properties"/>
        </bean>
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <property name="driverClass" value="${jdbc.driver}"/>
            <property name="jdbcUrl" value="${jdbc.url}"/>
            <property name="user" value="${jdbc.username}"/>
            <property name="password" value="${jdbc.password}"/>
        </bean>
        <!--引入Mybatis文件-->
        <bean class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <!-- 加载mybatis的配置文件 -->
            <!-- 当mybatis的xml文件和mapper接口不在相同包下时,需要用mapperLocations属性指定xml文件的路径。
    *是个通配符,代表所有的文件,**代表所有目录下 -->
            <!--强调:xxxMapper.xml配置在resources文件夹下,classpath*:没加*报错-->
            <property name="mapperLocations" value="classpath:org/ibaiqi/gather/dao/*.xml" />
        </bean>

        <!--加入事务-->
        <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"/>
        </bean>
    <!-- 通过扫描的模式,扫描目录在com.lanyuan.mapper目录下的mapper-->
    <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!--<property name="basePackage"-->
    <!-- <property name="basePackage" value="org.ibaiqi.gather.dao" /> 可以找到对象,调用方法错等解决-->
          <property name="basePackage" value="org.ibaiqi.gather.dao" />
    </bean>

</beans>

 

Connected to the target VM, address: 127.0.0.1:52959, transport: socket
服务层读取数据库-------
org.apache.ibatis.binding.MapperProxy@67fe380b

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.ibaiqi.gather.dao.RecruitGatherDao.listRecruitGathers

    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:225)
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
    at com.sun.proxy.$Proxy24.listRecruitGathers(Unknown Source)
    at org.ibaiqi.gather.service.imp.RecruitGatherServiceImp.listRecruitGathers(RecruitGatherServiceImp.java:33)
    at org.ibaiqi.gather.service.imp.RecruitGatherServiceImpTest.listRecruitGathers(RecruitGatherServiceImpTest.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Disconnected from the target VM, address: 127.0.0.1:52959, transport: socket

Process finished with exit code -1

 

原创: spring整合mybatis配置,包括错误调试改整,明天用半天时间来整理

标签:路径   repeat   ota   intellij   edm   star   span   config   cache   

原文地址:https://www.cnblogs.com/asplover/p/12430826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!