Explain in detail the spring boot + mybatis + freemaker framework built in MyEclipse
1. Create a maven project in MyEclipse. File>New>Maven Project:
Check the red part in the figure and click next.
2. Fill in the red part in the figure below and click finish.
3. A maven project has been generated. The directory structure is as follows:
4. Open POM Edit the following contents in XML:
5. Create program entry application java.
6. Create an application configuration file under Src / main / resources properties。
The corresponding configuration needs to be modified according to your actual situation.
7. Create the mybatis directory under Src / main / resources and create usermapper XML file:
8. Create usercontroller class and view file:
It can be seen that the list method returns a string. Because we loaded the freemaker module for the application to display the view, we need to create a list template. The directory where the template is located is in application Properties as spring freemarker. Template loader path = classpath: / templates /, so we need to create the templates directory under Src / main / resources, and then create the user directory under templates. The suffix of the template file is in application Properties as spring freemarker. suffix=. FTL, so finally create a list FTL file:
The directory structure where the template file is located is shown in the following figure:
9. Create userservice interface:
10. Create userserviceimpl class to implement userservice interface:
11. Create usermapper interface:
12. Create entity class user:
13. So far, the spring boot framework has been built, and then in application Run as > java application in Java. At this time, you will see the following log output on the console:
14. Open the browser and enter in the address bar http://localhost/user/list You can see the following effects:
15. In POM Right click Run as > Maven install on the XML file to package the project into a jar file. The generated jar is in the target directory. You can copy the jar to the server and run the project through "Java Jar - the name of the final generated jar package".
16. The source code of this project has been uploaded to spring boot_ jb51. Rar, friends in need can download it by themselves