Myeclispe下mybatis generator的使用

准备:下载附件包解压到myeclispe的dropins文件夹下
选择项目
1.新建config文件


配置路径




2.配置config
<?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="E:\lib\mysql-connector-5.1.8.jar" />
	  <context id="contextMybatis" >
	  		<!--数据库链接地址账号密码-->
		    <jdbcConnection driverClass="com.mysql.jdbc.Driver" 
		    	connectionURL="jdbc:mysql://192.168.126.128:3306/test?useUnicode=true&amp;characterEncoding=UTF-8" 
		    	userId="test" 
		    	password="test" />
		     <!--生成Model类存放位置-->
		    <javaModelGenerator targetPackage="Model" targetProject="Mybatis" />
		    <!--生成映射文件存放位置-->
		    <sqlMapGenerator targetPackage="Mapper" targetProject="Mybatis" />
		    <!--生成Dao类存放位置-->
		    <javaClientGenerator targetPackage="Dao" targetProject="Mybatis" type="XMLMAPPER" />
		    <!--生成对应表及类名-->
		    <table tableName="user"  
            domainObjectName="user" enableInsert="true"  
            enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="true"  
            enableDeleteByPrimaryKey="true" enableSelectByExample="false"  
            enableDeleteByExample="false" enableCountByExample="false"  
            enableUpdateByExample="false">  
        	</table>  
        	<table tableName="role"  
            domainObjectName="role" enableInsert="true"  
            enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="true"  
            enableDeleteByPrimaryKey="true" enableSelectByExample="false"  
            enableDeleteByExample="false" enableCountByExample="false"  
            enableUpdateByExample="false">  
        	</table>  
  	 </context>
</generatorConfiguration>

3.右击配置文件,点击下图矩形框选项即可


猜你喜欢

转载自donald-draper.iteye.com/blog/2309387