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
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
(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 ...
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>
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.
DrugMasters attributes defines must associate with the drug_id,drug_name,drug_alert_date,drug_alert_source, rownum .
2 Points to cover
Mapper:scan
covers the required package. If you are using annotation then @MapperScan(com.xxx)
must be in the defined path.