MyBatisGenerator的自动生成代码之MyEclipse
2017-07-06 10:41
323 查看
api
http://mbg.cndocs.tk/MyEclipse用MyBatiesGenerator自动生成跟Eclipse不同,MyEclipse不能安装MyBatiesGenerator插件
所以这里我们可以参考http://mbg.cndocs.tk/running/runningWithMaven.html这一章,通过maven手动添加一个插件,手动运行来编译generatorConfig.xml文件,
从而实现自动生成代码
generatorConfig.xml配置文件
[html] viewplain copy
<?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.mybatis.lesson04.mbg.entity" targetProject="E:\MyEclipse 8.5\Workspaces\MybatisLesson\src" />
<!--
生成接口映射的代码 java接口
-->
<sqlMapGenerator targetPackage="cn.et.mybatis.lesson04.mbg.dao" targetProject="E:\MyEclipse 8.5\Workspaces\MybatisLesson\src" />
<!--
生成xml或者注解
targetProject属性
XMLMAPPER 生成xml
ANNOTATEDMAPPER 生成注解
-->
<javaClientGenerator targetPackage="cn.et.mybatis.lesson04.mbg.dao" targetProject="E:\MyEclipse 8.5\Workspaces\MybatisLesson\src" type="XMLMAPPER" />
<!--
选择数据库的表
schema方案 每个用户都有一个唯一的方案,方案名等于用户名
tableName表名
把Example后缀的方法都关闭掉,用不上
-->
<table schema="scott" tableName="emp" enableCountByExample="false"
enableSelectByExample="false" enableDeleteByExample="false"
enableUpdateByExample="false"
>
</table>
</context>
</generatorConfiguration>
pom.xml
添加二个maven架包
[html] viewplain copy
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.3</version>
</dependency>
添加一个plugin标签
[html] viewplain copy
<!--
My Eclipse不能安装MBG
所以这里我们要配置一个插件来运行generatorConfig.xml配置文件
-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.3</version>
<!-- 告诉插件配置文件的路径 -->
<configuration>
<configurationFile>generatorConfig.xml</configurationFile>
</configuration>
<!-- 插件运行的过程中需要ojdbc架包的支持,所以在这里要配置ojdbc架包 -->
<dependencies>
<dependency>
<groupId>oracle</groupId>
<artifactId>orcale</artifactId>
<version>3.2.8</version>
<scope>system</scope>
<systemPath>C:\app\Administrator\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar</systemPath>
</dependency>
</dependencies>
</plugin>
运行插件
new一个插件
配置如下
最后Run就可以了
相关文章推荐
- 利用Myeclipse自动生成webService客户端代码
- 利用Myeclipse自动生成webService客户端代码
- Mybatis 代码自动生成[myeclipse版]
- myeclipse、MyEclipse注册码自动生成代码
- 使用Eclipse3.2(MyEclipse)+ abator自动生成iBatis代码以及配置文件的方法
- 利用Myeclipse自动生成webService客户端代码
- myEclipse2014集成MyBatis插件自动生成代码
- 使用MyEclipse自动生成WebService客户端代码
- myEclipse2014集成MyBatis插件自动生成代码
- (转)myeclipse自动生成注册码代码
- myEclipse7.5中安装 javascript,extjs的代码自动提示spket插件和extjs desiner可视化代码生成工具,extjs的一个很好的学习视频资源地址
- myeclipse 安装 ibatis 插件 自动生成java代码
- xfire框架构建webservice应用(通过myeclipse自动生成代码,自动导入xfire jar包,需要用jdk5.0)
- myeclipse自动生成代码SSH2
- JAVA-----myeclipse快捷操作:一段代码自动生成方法 refactor重构extract method抽取方法
- What:MyEclipse自动生成jsp页面代码结构
- 使用MyEclipse自动生成WebService服务端代码
- JAVA-----myeclipse快捷操作:一段代码自动生成方法 refactor重构extract method抽取方法
- 利用Myeclipse自动生成webService客户端代码
- idea使用generator插件自动生成代码工具遇到的问题