The SSM framework does not have a db+record pattern and is particularly laborious to write, and can only be done with the following methods.
, *.jar is downloaded, SRC is a new blank directory, and. XML is configured as follows.
<?XML version= "1.0" encoding= "UTF-8"?> <!DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis Generator Configuration 1.0//en" "/http Mybatis.org/dtd/mybatis-generator-config_1_0.dtd "> <generatorconfiguration> <!--Database-driven - <Classpathentry Location= "Mysql-connector-java-5.1.22-bin.jar"/> <ContextID= "Db2tables"Targetruntime= "MyBatis3"> <Commentgenerator> < Propertyname= "Suppressdate"value= "true"/> <!--whether to remove automatically generated comments true: Yes: false: No - < Propertyname= "Suppressallcomments"value= "true"/> </Commentgenerator> <!---Database link URL, user name, password - <jdbcconnectionDriverclass= "Com.mysql.jdbc.Driver"Connectionurl= "Jdbc:mysql://127.0.0.1/yanan?characterencoding=utf8"userId= "Yanan"Password= "1234"> </jdbcconnection> <Javatyperesolver> < Propertyname= "Forcebigdecimals"value= "false"/> </Javatyperesolver> <!--generate the package name and location of the model and create a new SRC folder where the current file is stored - <JavamodelgeneratorTargetpackage= "Test"Targetproject= "src"> < Propertyname= "Enablesubpackages"value= "true"/> < Propertyname= "Trimstrings"value= "true"/> </Javamodelgenerator> <!--Build the package name and location of the mapping file - <SqlmapgeneratorTargetpackage= "Test"Targetproject= "src"> < Propertyname= "Enablesubpackages"value= "true"/> </Sqlmapgenerator> <!--generate DAO's package name and location - <Javaclientgeneratortype= "Xmlmapper"Targetpackage= "Test"Targetproject= "src"> < Propertyname= "Enablesubpackages"value= "true"/> </Javaclientgenerator> <!--the table to be generated tablename is the name of the table or view in the database Domainobjectname is the entity class name. Only one table can be generated from a table - <TableTableName= "User"Domainobjectname= "User"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false"></Table> </Context> </generatorconfiguration>
View Code
In the current directory, open a command window and type the following command:
Java-jar Mybatis-generator-core-1.3.5.jar-configfile Generatorconfig.xml-overwrite
As you can see, the corresponding entity classes, mapping files, and entity class interfaces are generated under the corresponding directory of the SRC configuration. That's it.
Be careful not to listen to what is said on the Internet to find bin. Only one can be generated at a time. Ensure that the above files (tools) are in the same directory, any directory. On the configuration file, join the port
MyBatis automatically generate Java code