月度归档:2015年05月

eclipse中使用mybatis-generator

(1)从github下载eclipse插件:https://github.com/mybatis/generator/tree/master/eclipse/UpdateSite

(2)将features和plugins文件夹,拷贝都eclipse的安装文件夹下,和原有的features/plugins合并

(3)在eclipse中,File->New->Other->Mybatis,生成generatorConfig.xml

(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>
<classPathEntry
location=”C:/Users/Administrator/.m2/repository/mysql/mysql-connector-java/5.1.31/mysql-connector-java-5.1.31.jar” />
<context id=”context1″>
<jdbcConnection driverClass=”com.mysql.jdbc.Driver”
connectionURL=”jdbc:mysql://127.0.0.1:3306/mytest?useUnicode=true&amp;characterEncoding=UTF-8
userId=”root” password=”mysql1000″ />
<javaModelGenerator targetPackage=”com.web4399.mytest.mode”
targetProject=”monitor-share”>
<property name=”enableSubPackages” value=”true” />
</javaModelGenerator>
<sqlMapGenerator targetPackage=”com.web4399.mytest.map”
targetProject=”monitor-share”>
<property name=”enableSubPackages” value=”true” />
</sqlMapGenerator>
<javaClientGenerator targetPackage=”com.web4399.mytest.client”
targetProject=”monitor-share”
type=”XMLMAPPER”>
<property name=”enableSubPackages” value=”true” />
</javaClientGenerator>
<table schema=”” tableName=”dispatcher_job_run”>
</table>
</context>
</generatorConfiguration>

其中classPathEntry用于指定本地mysql-connector的jar包位置,targetProject设为generatorConfig.xml所在的工程名。

(5)在generatorConfig.xml上右键->Generate Mybatis