官网下载
https://github.com/mybatis/generator/releases
SSM
构建基础spring mvc
https://www.cnblogs.com/aeolian/p/11950980.html
整合Mybatis
除了mybatis官网下的mybatis-3.5.3.jar
<?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"/> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="false"/> </commentGenerator> <!--数据库链接URL,用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://222.222.221.138:3306/authplatform?useUnicode\=true&characterEncoding\=UTF-8" userId="root" password="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"/> </javaModelGenerator> <!-- 生成映射文件xml的包名和位置--> <sqlMapGenerator targetPackage="com.autumn.mapping" targetProject="src"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!-- 生成DAO接口的包名和位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.autumn.dao" targetProject="src"> <property name="enableSubPackages" value="true"/> </javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> <table tableName="account" domainObjectName="account" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="auth_role" domainObjectName="auth_role" enableCountByExample="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>
用java命令生成dao、mapper、pojo
java -jar mybatis-generator-core-1.4.0.jar -configfile generator.xml -overwrite