Mybatis-Generator
关于Mybatis-Generator的下载可以到这个地址:https://github.com/mybatis/generator/releases
由于我使用的是Mysql数据库,这里需要在准备一个连接mysql数据库的驱动jar包
generatorConfig.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE generatorConfiguration 3 PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" 4 "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> 5 <generatorConfiguration> 6 <!--数据库驱动--> 7 <classPathEntry location="mysql-connector-java-5.0.8-bin.jar"/> 8 <context id="DB2Tables" targetRuntime="MyBatis3"> 9 <commentGenerator> 10 <property name="suppressDate" value="true"/> 11 <property name="suppressAllComments" value="true"/> 12 </commentGenerator> 13 <!--数据库链接地址账号密码--> 14 <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/mymessages" userId="root" password="root"> 15 </jdbcConnection> 16 <javaTypeResolver> 17 <property name="forceBigDecimals" value="false"/> 18 </javaTypeResolver> 19 <!--生成Model类存放位置--> 20 <javaModelGenerator targetPackage="lcw.model" targetProject="src"> 21 <property name="enableSubPackages" value="true"/> 22 <property name="trimStrings" value="true"/> 23 </javaModelGenerator> 24 <!--生成映射文件存放位置--> 25 <sqlMapGenerator targetPackage="lcw.mapping" targetProject="src"> 26 <property name="enableSubPackages" value="true"/> 27 </sqlMapGenerator> 28 <!--生成Dao类存放位置--> 29 <javaClientGenerator type="XMLMAPPER" targetPackage="lcw.dao" targetProject="src"> 30 <property name="enableSubPackages" value="true"/> 31 </javaClientGenerator> 32 <!--生成对应表及类名--> 33 <table tableName="message" domainObjectName="Messgae" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> 34 </context> 35 </generatorConfiguration>