In order to comb the previous study of "Spring integration MyBatis (maven+mysql) One" and "Spring Integration MyBatis (maven+mysql) II" in the content, Get ready to do a complete example of a simple book management function, with the main technologies used include spring, MyBatis, maven, and MySQL. The final performance is as follows:
The project structure is as follows:
I. Create a new MAVEN-based Web project
1.1. Create a simple MAVEN project with the following project information:
1.2, modify the level of information, on the project right-click on the property, and then select "Project Facets", first set the Java Runtime Environment is 1.7, first remove the "Dynamic Web Module" before the tick, and then save the close, and then open the tick "dynamic web Module ", version select" 3.0 "; Here a hyperlink appears in the left-hand solution, creating" Web Content "to complete the shutdown.
1.3. Modify the deployment content of the project. On the project right-click Properties, select "Deplyment Assembly", delete the content that does not need to be published such as: two directories with "test", WebContent directory, and add a WebApp directory under Main.
The result of the modification is as follows:
1.4. Modify the contents of the project. Copy the contents under WebContent to/src/main/webapp, and then delete the WebContent directory, and the modified results are as follows:
1.5. Add "Server Runtime" and add the following results:
Ii. Creating databases and tables
Third, add dependency
Iv. New Pojo entity layer
V. New MyBatis SQL mapping layer
Vi. Creating a service layer
VII. complete Spring Integrated mybatis configuration
Viii. creating Servlets and implementing features
Nine, Test run
Spring Integrated MyBatis Complete Example