mybatis spring mvc application, getting Invalid bound statement (not found)

后端 未结 17 2219
猫巷女王i
猫巷女王i 2020-12-09 17:04

this is my first mybatis spring mvc application using spring 3.2.4, mybatis-spring-1.2.1

When i try to call my webservice i get the error::

org.spri         


        
相关标签:
17条回答
  • 2020-12-09 17:28

    I have also encountered this problem in my development. In generall, if you are using xml configuration files for spring,myBatis and etc., then this problem is mostly caused by some mistake in your xml configuration files.

    The most voted answer by Dariusz demonstrated that there maybe some problems in the myBatis xml configuration file, while in my case, I found that problems in spring xml configuration file can also result in this problem.

    In the situation of this post, in the applicationContext.xml(which should be a configuration file of Spring), we can see a basePackage configuration for the MapperScannerConfigurer:

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="org.mydomain.formulary.mappers" /> </bean>

    so if the value for this property is wrong(the package name is not right), it will also result in this problem.

    0 讨论(0)
  • 2020-12-09 17:29

    In my case it was a typo error in the id of the mapper xml statement e.g.

    <select id="getDtaa" resultType="Data">
    
    List<T> getData()
    

    After changing the id in the XML to the correct function name it worked.

    0 讨论(0)
  • 2020-12-09 17:30

    in the spring configuration, taking a xml way for example, make sure that the mapper.xml files are located at the place assigned as the value of the property named mapperLocations. Once I had it at mappers/anotherfolder/*.xml. And that causes the pain.

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="typeAliasesPackage" value="somepackage.model"/>
        <property name="mapperLocations" value="classpath*:mappers/*.xml"/>
    </bean>
    
    0 讨论(0)
  • 2020-12-09 17:31

    Except for @Dariusz mentioned above, I've also forgotten to add mapper location.

    <property name="mapperLocations" value="classpath:mybatis/mappers/*.xml"/>
    
    0 讨论(0)
  • 2020-12-09 17:31

    Check if there is any overload method in mapper. Try to use a separate name instead.

    0 讨论(0)
提交回复
热议问题