The project uses sring MVC + mybatis combination. Here is a brief introduction to the application of mybatis:
My IDE is STS (Spring + tool + suite). The installation of mybatis generator plug-in is the same as that in myeclipse,
1.Run "help --" install new solftware -- "add" in IDE as shown in:
Enter mybatis plug-in address http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite/
2. Create an XML file under the project named MyBatis-config.xml
The content configuration is as follows:
1 <? XML version = "1.0" encoding = "UTF-8"?> 2 <! Doctype generatorconfiguration public "-// mybatis.org//dtd mybatis Generator configuration 1.0 //" http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd "> 3 <generatorconfiguration> 4 <classpathentry 5 Location =" C: \ Users \ Administrator \. m2 \ repository \ mysql-connector-Java \ 5.1.31 \ mysql-connector-java-5.1.31.jar "/> 6 7 <context ID =" context1 "> 8 9 <! -- Remove automatically generated comments --> 10 <commentgenerator> 11 <property name = "suppressallcomments" value = "true"/> 12 <property name = "suppressdate" value = "true" /> 13 </commentgenerator> 14 15 <jdbcconnection driverclass = "com. mySQL. JDBC. driver "16 connectionurl =" JDBC: mysql: // 127.0.0.1: 3306/manager? Useunicode = true & amp; characterencoding = UTF-8 "17 userid =" root "Password =" 123456 "/> 18 19 <! -- Model layer corresponding to the data table --> 20 <javamodelgenerator targetpackage = "com. wjq. test. manager. domain "21 targetproject =" Manager/src/main/Java "/> 22 23 <! -- SQL mapper ing configuration file --> 24 <sqlmapgenerator targetpackage = "com. wjq. test. manager. dao. mapper "25 targetproject =" Manager/src/main/Java "/> 26 27 <! -- Generate Dao object --> 28 <javaclientgenerator targetpackage = "com. wjq. test. manager. dao "29 targetproject =" Manager/src/main/Java "type =" xmlmapper "> 30 <property name =" enablesubpackages "value =" true "/> 31 </javaclientgenerator> 32 33 <! -- Generate related interface methods --> 34 <Table schema = "test" tablename = "testphone" 35 domainobjectname = "testphone" enableinsert = "true" 36 enableselectbyprimarykey = "true" enableupdatebyprimarykey = ""True" 37 cases = "true" enableselectbyexample = "false" 38 enabledeletebyexample = "false" enablecountbyexample = "false" 39 enableupdatebyexample = "false"> 40 </table> 41 </ context> 42 </generatorconfiguration>
3. Right-click Generate mybatis on the configured MyBatis-config.xml to generate the corresponding file you configured.
The above is the work and study income. If there is any improper situation, please leave a message for discussion, and mark the source for reprinting. Thank you.
Mybatis Generator configuration file and description