Implementation method of simulating mybatis
Other tools or technologies required:
Project management tool: maven
Test run tool: JUnit
Database: Derby
XML manipulation tool: Dom4j
Keep talking nonsense
Maven Dependencies:
SQL table creation and data insertion (if you have done so in Section 1, you can skip this step):
The mybatis configuration file is located in the Src / main / resource source directory
User. Java object class (under Src / main / Java / COM / bjpowernode / practice directory)
Select. Java annotation class (under Src / main / Java / COM / bjpowernode / practice / annotation directory)
UserMapper. Java annotation based configuration class (under Src / main / Java / COM / bjpowernode / practice / annotation directory)
Mapper. Java object class (under Src / main / Java / COM / bjpowernode / practice / simulation directory)
sqlSelectProxy. Java AOP dynamic proxy class (under Src / main / Java / COM / bjpowernode / practice / simulation directory)
sqlSession. Java mybatis simulation interface (under Src / main / Java / COM / bjpowernode / practice / simulation directory)
sqlSessionFactory. Java mybatis simulation class (under Src / main / Java / COM / bjpowernode / practice / simulation directory)
sqlSessionFactoryBuilder. Java mybatis simulation class (under Src / main / Java / COM / bjpowernode / practice / simulation directory)
sqlSessionImpl. Java mybatis simulation class (under Src / main / Java / COM / bjpowernode / practice / simulation directory)
UserMapper. XML mapper configuration file based on XML (under Src / main / Java / COM / bjpowernode / practice / XML directory)
TestMyBatis. Java test class (under Src / test / Java / COM / bjpowernode / practice directory)
The above is a simple simulation of mybatis based on XML and annotation. To understand how mybatis works.
I always think that when learning a tool technology, the route should be
1. Implement a small example
2. Find materials and understand the principle
3. Learn the technical details and implement them by hand
4. After all learning, start a small project and use all links in the technology as much as possible.
summary
The above is the implementation method of simulated mybatis introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!