您的位置:首页 > 其它

mybatis逆向工程生成相关文件

2017-11-30 10:47 267 查看
前面一篇博文中谢了使用插件方式生成mybatis相关文件,下面介绍下使用maven依赖的方式。这里演示使用idea

1. pom.xml配置

<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>src/main/resources/mybatis-generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
</dependencies>
</plugin>


2.新建mybatis-generatorConfig.xml

在pom.xml配置的

<configurationFile>src/main/resources/mybatis-generatorConfig.xml</configurationFile>


对应目录下新建mybatis-generatorConfig.xml

3.配置mybatis-generatorConfig.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>
<context id="mysqlgenerator" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true"/> <!--是否取消注释-->
<property name="suppressDate" value="true"/> <!--是否生成注释时间戳-->
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/springsecurity?characterEncoding=UTF-8"
userId="root"
password="299522" />
<!--指定生成java类型-->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.awna.model" targetProject="src/main/java" />

<sqlMapGenerator targetPackage="mappers" targetProject="src/main/resources" />

<javaClientGenerator type="XMLMAPPER" targetPackage="com.awna.dao" targetProject="src/main/java" />

<table tableName="SYS_USER" domainObjectName="SysUser"
enableCountByExample="false" enableUpdateByExample="false"
enableSelectByExample="false" enableDeleteByExample="false"
selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</table>
<table tableName="SYS_ROLE" domainObjectName="SysRole"
enableCountByExample="false" enableUpdateByExample="false"
enableSelectByExample="false" enableDeleteByExample="false"
selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</table>
<table tableName="SYS_ROLE_USER" domainObjectName="SysRoleUser"
enableCountByExample="false" enableUpdateByExample="false"
enableSelectByExample="false" enableDeleteByExample="false"
selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</table>
<table tableName="Sys_permission" domainObjectName="SysPermission"
enableCountByExample="false" enableUpdateByExample="false"
enableSelectByExample="false" enableDeleteByExample="false"
selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</table>
<table tableName="Sys_permission_role" domainObjectName="SysPermissionRole"
enableCountByExample="false" enableUpdateByExample="false"
enableSelectByExample="false" enableDeleteByExample="false"
selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</table>
</context>

</generatorConfiguration>


4.运行逆向工程

首先配置idea



运行
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: