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
In my case, using a query in an annotation, i didn't give enough credit to the fact that the XML in the annotation gets interpreted as XML.
So if you have
@Select("select * from table where id <> 'blabla'")
The <>
is messing up the XML. You need to put it in a CDATA section
@Select("select * from table where id <![CDATA[ <> ]]> 'blabla'")
I googled this answer when looking for my error. It's actually unrelated to OP's problem, but the exception is the same and this question's very visible in google.
In my case I forgot to change the mapper namespace
<mapper namespace="pl.my.package.MyNewMapper">
Which resulted in the same problem.
I resolved the same problem with a variant of the solution of Giovanni Perea(thank you). I have the .xml mapper files in the same folder with .java mapper files and I using maven with maven-resources-plugin.
In my solution I have add an execution in maven-resources-plugin for copy all the .xml mapper file to the correct location(same folder of the .class mapper files):
<execution>
<id>copy-mappers-xml</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/com/myapplication/mapper</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/java/com/myapplication/mapper/</directory>
<filtering>false</filtering>
<includes>
<include>*.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
More examples with maven-resources-plugin: Including and excluding files and directories
If you do not use maven-resources-plugin see: https://stackoverflow.com/a/12446666/2473158
Rename mapper/drugmasterDao.xml to mapper/DrugMasterDao.xml , the name has to match the *Dao.java file name otherwise it throws error or we have to create Ibatismapping.xml explictly and add mapper configuration there
I had the same problem so after reading the configurations in this page. https://mybatis.github.io/spring/mappers.html#scan
I saw that my configuration was correct. so debugging my application. found that my *mappers.xml files where not in the path. that expect must be.
I had the XML files in the same folder src "java" in my maven project. so when I build my applications the file were not copy to classes folder. So I have to move the xml files to folder "resources". and the fix the problem.
In my case, I had multiple DataSource
and should set mappler locations for each SessionFactory
.
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(mysqlDataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sessionFactory.setMapperLocations(resolver.getResources("classpath:mappers/**/*Mapper.xml"));