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

后端 未结 17 2218
猫巷女王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:08

    most likely the java method name and the XML block's name mismatches

    e.g mapper.getUser()  
    
     <select id="getUsee" resultMap="student">
        ...........
     <>
    

    getUser obviously different from getUsee

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

    (There could be many reasons, my case is a bit rare & weird, it's hard to discover, so I'd like to add an answer here, just in case someone did the same thing as me.)

    In my case, then reason is in IDEA, when create multi-level package for mapper file I input mybatis.mapper, which only create a single dir but with name contains ..

    While I should actually input mybatis/mapper to create multi-level dir at once.

    In these 2 cases, the dir are shown the same as mybatis.mapper in the project view of IDEA, so it took me quiet a while to figure out why ...

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

    Because your xml not load in mybatis, MapperScannerConfigurer only scan interface, not xml. Have two way:

    <mappers>
        <mapper resource="org/mydomain/formulary/mappers/drugmasterDao.xml"/>
    </mappers>
    

    or

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
        <property name="dataSource" ref="dataSource"/>
        <property name="mapperLocations" value="classpath*:org/mydomain/**/*.xml"/>
    </bean>
    
    0 讨论(0)
  • 2020-12-09 17:15

    i had similar problem for my spring-boot mybatis application. The issue was mybatis couldn't find the configuration file. After adding

    mybatis.config-location=classpath:mybatis-config.xml
    

    in the application.properties file, issue got resolved. Looks like issue is always around configuration files/mapper files and statement names.

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

    DrugMasters attributes defines must associate with the drug_id,drug_name,drug_alert_date,drug_alert_source, rownum .

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

    2 Points to cover

    1. Check whether the method name is the same in both the XML and Java methods.
    2. Mapper:scan covers the required package. If you are using annotation then @MapperScan(com.xxx) must be in the defined path.
    0 讨论(0)
提交回复
热议问题