Posted by mikevegap
on December 23, 2010 at 9:25 PM PST
A simple demo of the Spring and mybatis integration
In this post I show how simple is to integrate mybatis and spring framework.
Mybatis needs to setup the DAO interfaces and behaviours.
Till here spring and mybatis works perfectly, but the last two files can be avoided just by taking advantage of some annotations and
The line 27 from the applicationContext.xml can be ignored if we make the following changes in the WorkerDAO interface:
makes useless the implementation of both mybatis-config.xml and WorkerDao.xml configuration files, that's because mybatis is able
to recognize the parameters and type of the objects to be returned from DAO interface, so there's no need to map them explicitly.
This means that they aren't necessary to make this example work, so they don't need to be in this example.
Consider is the proper way to handle the transactions based on the application needs, 'cause using XML mapper files avoids the hardcoding of the SQL statements.
Ok, the example above demonstrate how easy is to integrate SpringFramework 3 and Mybatis 3
I hope this post has been helpful for you...