SSM generates the dao layer MybatisGenerator

Official website to download

mybatis generator

Download the generator of the release version mybatis-generator-core-1.4.0-bundle.zip

https://github.com/mybatis/generator/releases

mybatis generator

generator.xml

<?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>  
<!-- 数据库驱动-->  
    <classPathEntry  location="D:\workspace6_5\HjzzAuthPlatform\mysql-connector-java-5.1.22-bin.jar"/>  
    <context id="DB2Tables"  targetRuntime="MyBatis3">  
        <commentGenerator>  
            <property name= "suppressDate" value = "true" />   
            ! <- whether to remove the automatically generated annotations true: is: to false: NO ->   
            < Property name = "suppressAllComments" value = "to false" />   
        </ commentGenerator >   
        < ! - database link URL, user name, password ->   
        < JdbcConnection driverClass = "com.mysql.jdbc.Driver"  
            connectionURL = "jdbc: MySQL: //222.222.221.138: 3306 / authplatform useUnicode \ = to true & amp; characterEncoding? \ = UTF-. 8 "  
          the userId =" the root " password =" the root " >  
        </jdbcConnection>  
        <javaTypeResolver>  
            <property name="forceBigDecimals" value="false"/>  
        </javaTypeResolver>  
        <!-- 生成pojo的包名和位置-->  
        <javaModelGenerator targetPackage="com.autumn.model" targetProject="src">  
            <property name="enableSubPackages" value="true"/>  
            <property name="trimStrings" value="true"/>  
        </ ->Package name and location of the mapping file generation xml<-!>JavaModelGenerator  
          
        <sqlMapGenerator targetPackage="com.autumn.mapper" targetProject="src">
            <property name="enableSubPackages" value="true"/>  
        </sqlMapGenerator>  
        <!-- 生成DAO接口的包名和位置-->  
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.autumn.mapper" targetProject="src">
            <property name="enableSubPackages" value="true"/>  
        </javaClientGenerator>
        <!--To generate a table tableName database table or view name domainObjectName entity class name ->   
        < Table tableName = "Account" domainObjectName = "the Account" enableCountByExample = "to false" enableUpdateByExample = "to false" enableDeleteByExample = "to false" enableSelectByExample = "to false" selectByExampleQueryId = "to false" > </ Table > 
        < Table tableName = "auth_role" domainObjectName = "auth_role" enableCountByExample = "to false" enableUpdateByExample = "false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        <table tableName="auth_system" domainObjectName="Auth_system" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        
    </context>  
</generatorConfiguration>

The download of the mybatis-Generator-Core-1.4.0.jar, generator.xml (need to specify the mysql-connector-java-5.1.22- bin.jar) into the directory with the following items.

java command

Generating dao, mapper java command using, pojo

java -jar mybatis-generator-core-1.4.0.jar -configfile generator.xml -overwrite

Maven

If maven, generator.xml into the following projects, pom.xml with the following configuration, maven of targetProject ordinary myeclipse project is not the same, you need to change targetProject.

      <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.2</version>
      </dependency>
      <plugin>
            <groupId>org.mybatis.generator</groupId>           <artifactId>mybatis-generator-maven-plugin</artifactId>           <version>1.3.2</version>     </plugin>

Guess you like

Origin www.cnblogs.com/aeolian/p/11981020.html