@wxf
2017-06-03T16:40:53.000000Z
字数 1785
阅读 1010
项目实战
MyBatis逆向工程就是根据数据表生成java代码。搭建逆向工程的步骤如下所示:
<generatorConfiguration><!--指定特定数据库的jdbc驱动jar包的位置--><classPathEntry location="D:\Maven\resource\mysql\mysql-connector-java\5.1.32\mysql-connector-java-5.1.32.jar"/><context id="testTables" targetRuntime="MyBatis3"><commentGenerator> <!-- 是否去除自动生成的注释 --><property name="suppressAllComments" value="true" /></commentGenerator><jdbcConnectiondriverClass="com.mysql.jdbc.Driver"connectionURL="jdbc:mysql://localhost:3306/mmall"userId="root"password="123456"> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --></jdbcConnection><!--默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为true时把JDBC DECIMAL 和 NUMERIC类型解析为BigDecimal--><javaTypeResolver><property name="forceBigDecimals" value="false" /></javaTypeResolver><!-- targetProject:生成POJO类的位置 --><javaModelGenerator targetPackage="com.wxf.pojo" targetProject=".\src\main\java"><property name="enableSubPackages" value="false" /><property name="trimStrings" value="true" /></javaModelGenerator><!-- targetProject:mapper映射文件生成的位置 --><sqlMapGenerator targetPackage="com.wxf.persist" targetProject=".\src\main\resources"><property name="enableSubPackages" value="false" /></sqlMapGenerator><!-- targetPackage:mapper接口生成的位置 --><javaClientGenerator type="XMLMAPPER" targetPackage="com.wxf.persist" targetProject=".\src\main\java"><property name="enableSubPackages" value="false" /></javaClientGenerator><!-- 指定数据库表 --><table tableName="mmall_product"domainObjectName="Product"enableCountByExample="false"enableUpdateByExample="false"enableDeleteByExample="false"enableSelectByExample="false"selectByExampleQueryId="false"><columnOverride column="detail" jdbcType="VARCHAR" /><columnOverride column="sub_images" jdbcType="VARCHAR" /></table></context></generatorConfiguration>
2. 列表项
在Maven Projects中找到mybatis-generator,双击执行。
