idea mybaits逆向工程_IDEA—Mybatis逆向工程

mybaits需要程序员自己编写sql语句,mybatis官方提供逆向工程,可以针对单表自动生成mybatis执行所需要的代码(mapper.java,mapper.xml、po..)

1. 下载逆向工程,配置Maven pom.xml 文件

SpringMVCBasic

org.mybatis.generator

mybatis-generator-maven-plugin

1.3.2

true

true

1. 生成代码配置文件

在maven项目下的src/main/resources 目录下新建generatorConfig.xml和generator.properties配置文件

generator.properties

jdbc.driverLocation=C:\\Users\\Yvettee\\.m2\\repository\\mysql\\mysql-connector-java\\5.1.18\\mysql-connector-java-5.1.18.jar

jdbc.driverClass=com.mysql.jdbc.Driver

jdbc.connectionURL=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8

jdbc.userId=root

jdbc.password=root

generatorConfig.xml

/p>

PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"

"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

driverClass="${jdbc.driverClass}"

connectionURL="${jdbc.connectionURL}"

userId="${jdbc.userId}"

password="${jdbc.password}">

targetProject="src/main/java">

targetProject="src/main/java">

targetProject="src/main/java" type="XMLMAPPER">

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

2. 在Intellij IDEA添加一个“Run运行”选项

使用maven运行mybatis-generator-maven-plugin插件

添加插件1

新添加Maven运行选项

3. 在name和Commond line分别填上如上图所示,再点击Apply和OK。

image.png

4. 最后再运行generate

点击generate

5. 结果

结果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值