SSM Framework Building (iii) database creation and MyBatis generators automatically generate entity classes, DAO interfaces, and Mapping mapping files

Source: Internet
Author: User

One: Create a database

Create a student table

DROP TABLE IF EXISTS' Student '; CREATE TABLE' Student ' (' ID ')int( One) not NULLauto_increment, 'user_name`varchar( +) not NULL, ' password 'varchar(255) not NULL, ' age 'int(4) not NULL,    PRIMARY KEY(' id ')) ENGINE=InnoDB auto_increment=2 DEFAULTCHARSET=UTF8;Insert   into' Student ' (' id ', 'user_name', ' password ', ' age ')Values(1,'Mai Mai','123456', -);

Two:

Configure Generatorconfig.xml

<?XML version= "1.0" encoding= "UTF-8"?>  <!DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis Generator Configuration 1.0//en" "Http://myba Tis.org/dtd/mybatis-generator-config_1_0.dtd ">  <generatorconfiguration>  <!--Database-driven -      <Classpathentry Location= "Mysql-connector-java-5.1.25-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/maimai"userId= "Maimai"Password= "123456">          </jdbcconnection>          <Javatyperesolver>              < Propertyname= "Forcebigdecimals"value= "false"/>          </Javatyperesolver>          <!--Build the package name and location of the model -          <JavamodelgeneratorTargetpackage= "Com.maimai.pojo"Targetproject= "src">              < Propertyname= "Enablesubpackages"value= "true"/>              < Propertyname= "Trimstrings"value= "true"/>          </Javamodelgenerator>          <!--Build the package name and location of the mapping file -          <SqlmapgeneratorTargetpackage= "Com.maimai.mapping"Targetproject= "src">              < Propertyname= "Enablesubpackages"value= "true"/>          </Sqlmapgenerator>          <!--generate DAO's package name and location -          <Javaclientgeneratortype= "Xmlmapper"Targetpackage= "Com.maimai.IDao"Targetproject= "src">              < Propertyname= "Enablesubpackages"value= "true"/>          </Javaclientgenerator>          <!--the table TableName to be generated is the name of the table or view in the database Domainobjectname is the entity class name -          <TableTableName= "user_t"Domainobjectname= "User"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false"></Table>    </Context>  </Generatorconfigurati

You can now build the

CD H:\mybatis-generator-core-1.3.2\lib

H:

Java-jar Mybatis-generator-core-1.3.2.jar-configfile Generatorconfig.xml-overwrite

Open and look, the build succeeds

Then copy the COM folder and put it here.

The creation of the database and the generation of the class are finished here, and the next step is to start Springmvc and MyBatis configuration

SSM Framework Building (iii) database creation and MyBatis generators automatically generate entity classes, DAO interfaces, and Mapping mapping files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.