How to achieve integration of mybatis and spring
1. Organize your ideas:
Spring is required to manage sqlsessionfactory in a single case .
Spring and mybatis Consolidate build proxy objects and use sqlsessionfactory to create sqlsession . (Spring and mybatis Integration Auto-complete)
The mapper of the persistence layer needs to be managed by Spring .
2. Integrated environment:
Jar Package:
Spring's jar package,
MyBatis's jar package,
And Spring-mybatis's integrated Jarbao.
3. Configure the XML file
Configure sqlsessionfactory and data sources in Applicationcontext.xml to inject sqlsessionfactory and mapper
In the Mapper.xml configuration implementation method
4. Implement
Get the ApplicationContext in the test method, get the injected mapper through ApplicationContext, and call the method in Mapper
Software Engineering Week sixth work