MyBatisGenerator的自动生成代码之Eclipse
2017-06-15 21:11
387 查看
下载地址:
https://github.com/mybatis/generator/releases然后在Eclipse中安装
选择刚刚下载的压缩包,再随便起一个name
Contact allu update... 取消自动更新
再勾选MyBaties Generator 那二项
创建一个简单的项目
配置maven
设置user settings
加载架包Mybatis
pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.et</groupId> <artifactId>Mybatis</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> </dependency> </dependencies> </project>
加载架包ojdbc
直接build path吧生成MyBatiesGenerator配置文件
new一个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> <!-- api --> <!--http://mbg.cndocs.tk/--> <context id="context1"> <!-- 生成根配置文件(jdbc) --> <jdbcConnection connectionURL="jdbc:oracle:thin:@localhost:1521:orcl" driverClass="oracle.jdbc.OracleDriver" password="tiger" userId="scott" /> <!-- 生成emp表的mybatis代码 生成emp的实体类 将表当成类名 列名当成属性名 targetPackage包类 targetProject生成在哪个项目里 --> <javaModelGenerator targetPackage="cn.et.mabatis.entity" targetProject="Mybatis/src/main/java" /> <!-- 生成接口映射的代码 java接口 --> <sqlMapGenerator targetPackage="cn.et.mabatis.dao" targetProject="Mybatis/src/main/java" a25c /> <!-- 生成xml或者注解 targetProject属性 XMLMAPPER 生成xml ANNOTATEDMAPPER 生成注解 --> <javaClientGenerator targetPackage="cn.et.mabatis.dao" targetProject="Mybatis/src/main/java" type="XMLMAPPER" /> <!-- 选择数据库的表 schema方案 每个用户都有一个唯一的方案,方案名等于用户名 tableName表名 把Example后缀的方法都关闭掉,用不上 --> <table schema="scott" tableName="emp" enableCountByExample="false" enableSelectByExample="false" enableDeleteByExample="false" enableUpdateByExample="false" > </table> </context> </generatorConfiguration>
运行配置文件
相关文章推荐
- 使用Eclipse的Generator MyBatis/iBatis Artifacts插件自动生成代码,与spring集成
- eclipse使用mybatis generator自动生成代码
- MyBatisGenerator的自动生成代码之Eclipse
- eclipse使用mybatis generator自动生成代码报错Generation Warnings Occured Project E: does
- Mybatis Generator Configuration Eclipse自动生成代码工具使用及实现基本crud
- 使用Eclipse的Generator MyBatis/iBatis Artifacts插件自动生成代码,与spring集成
- eclipse中 使用mybatis generator自动生成代码 错误
- 使用Mybatis Generator自动生成Mybatis相关代码
- MyBatis使用Generator自动生成代码
- MyBatis使用Generator自动生成代码
- MyBatisGenerator 自动生成java代码(反向工具)
- 使用Mybatis Generator自动生成Mybatis相关代码
- 使用Mybatis Generator自动生成Mybatis相关代码
- 使用Mybatis Generator自动生成Mybatis相关代码
- 使用MyBatis-Generator自动生成代码
- MyBatis使用Generator自动生成代码
- 一双跑鞋的mybatis(六)---使用generator自动生成mybatis映射代码
- maven+mybatis+mybatis-generator+sql server 2005自动生成代码,加上自定义分页插件和批量插入更新插件
- mybatis使用generator自动生成代码时的类型转换
- maven + MyBatis Generator 自动生成代码配置