MyBatis Generator安装及使用说明

来源:互联网 发布:python 字典列表排序 编辑:程序博客网 时间:2024/05/21 07:14

Mybatis Generator安装及使用

安装

1、下载mybatis-generator-eclipse插件。

2、解压,将featuresplugins拷贝到eclipse对应目录下,重启eclipse

3file->new,出现MyBatis Generator Configuration File即表明generator安装成功。

使用

1新建dynamic web project

2右键srcnew ->source folder,main.resources;右键resourcesnew->packagecom;右键srcnew ->source folder,main.java

3右键com,new->MyBatis->MyBatis Generator Configuration File

4、配置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="context1">

<commentGenerator>

<!-- 是否去除自动生成的注释 .true:是 ;false:否 -->

<property name="suppressAllComments" value="true" />

</commentGenerator>

<!-- 数据库链接URL、用户名、密码 -->

<jdbcConnection connectionURL="jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:xxx"

driverClass="oracle.jdbc.driver.OracleDriver" password="xxx"

userId="xxx" />

<!-- 生成模型的包名和位置 -->

<javaModelGenerator targetPackage="com.seal.machine.domain"

targetProject="MyBatisGenerator/src/main/java" />

<!-- 生成的映射文件报名和位置 -->

<sqlMapGenerator targetPackage="com.seal.machine.domain"

targetProject="MyBatisGenerator/src/main/java" />

<!-- 生成DAO的包名和位置 -->

<javaClientGenerator targetPackage="com.seal.machine.domain"

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

<!-- 要生成的表(更改tableNamedomainObjectName即可) -->

<table schema="" tableName="SEAL_MACHINE" domainObjectName="SealMachine"

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

</table>

</context>

</generatorConfiguration>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

5、向WEB-INF/lib下添加ojdbc.jarbuild path。需要注意的是,oracle12需要使用ojdbc6-xxx.jar

6、右键generatorConfig.xmlgenerate MyBatis/IBATIS Artifacts,即可看到生成的文件。

7、将生成的文件拷贝到目标项目,并按需进行修改。

0 0
原创粉丝点击