myeclipse mybatis generator 怎么使用
展开全部
命令窗口中执行:java -jar mybatis-generator-core-1.3.1.jar -configfile genrator.xml -overwrite
配置文件:
<?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:数据库的JDBC驱动,换成你自己的驱动位置 -->
<classPathEntry location="D:\test\mysql-connector-java-5.1.18.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- 去除自动生成的注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/antopporter" userId="root" password="root">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:自动生成代码的位置 -->
<javaModelGenerator targetPackage="com.test.model" targetProject="D:\test">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.test.mapping" targetProject="D:\test">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.test.dao" targetProject="D:\test">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
<table tableName="zy_server" domainObjectName="ZyServer" />
<table tableName="zy_resource_type" domainObjectName="ZyResourceType" />
<table tableName="zy_resource_type" domainObjectName="ZyResourceType" />
<table tableName="zy_resource_group" domainObjectName="ZyResourceGroup" />
<table tableName="zy_resource" domainObjectName="ZyResource" />
<table tableName="zy_view" domainObjectName="ZyView" />
<table tableName="zy_measurement_classify" domainObjectName="ZyMeasurementClassify" />
<table tableName="zy_measurement_group" domainObjectName="ZyMeasurementGroup" />
<table tableName="zy_measurement_group_templ" domainObjectName="ZyMeasurementGroupTempl" />
</context>
</generatorConfiguration>
在放上对应的jar包 即可执行
配置文件:
<?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:数据库的JDBC驱动,换成你自己的驱动位置 -->
<classPathEntry location="D:\test\mysql-connector-java-5.1.18.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- 去除自动生成的注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/antopporter" userId="root" password="root">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:自动生成代码的位置 -->
<javaModelGenerator targetPackage="com.test.model" targetProject="D:\test">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.test.mapping" targetProject="D:\test">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.test.dao" targetProject="D:\test">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
<table tableName="zy_server" domainObjectName="ZyServer" />
<table tableName="zy_resource_type" domainObjectName="ZyResourceType" />
<table tableName="zy_resource_type" domainObjectName="ZyResourceType" />
<table tableName="zy_resource_group" domainObjectName="ZyResourceGroup" />
<table tableName="zy_resource" domainObjectName="ZyResource" />
<table tableName="zy_view" domainObjectName="ZyView" />
<table tableName="zy_measurement_classify" domainObjectName="ZyMeasurementClassify" />
<table tableName="zy_measurement_group" domainObjectName="ZyMeasurementGroup" />
<table tableName="zy_measurement_group_templ" domainObjectName="ZyMeasurementGroupTempl" />
</context>
</generatorConfiguration>
在放上对应的jar包 即可执行
2016-01-09 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
工具是Myeclipse10和mybatis-generator-core-1.3.1,数据库是oracle
1.下载mybatis-generator-core-1.3.1-bundle,导入mybatis-generator-core-1.3.1.jar和myeclipse3.1.1.jar
2.编写生成器的配置文件generatorConfig.xml.
这个配置文件是生成器的主要文件,放在src目录下,这里只介绍基本的配置,具体介绍可以到官网查询
<?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="D:/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc5.jar" />
<context id="MBG" targetRuntime="MyBatis3">
<!-- 数据库配置 -->
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
userId="sys"
password="123456">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- model配置 -->
<javaModelGenerator targetPackage="com.common.model" targetProject="\MBGTestProject\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- xml配置文件 -->
<sqlMapGenerator targetPackage="com.common.model" targetProject="\MBGTestProject\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!--接口-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.common.dao" targetProject="\MBGTestProject\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table tableName="BASE_USERS" domainObjectName="Users" >
</table>
</context>
</generatorConfiguration>
在<table>里不要写schema属性,否则会报错,这个应该是mybatis-generator的bug
targetProject是项目的根路径,targetPackage是相应文件的包路径
3.执行generatorConfig.xml. 生成代码
在myeclipse10里右键单击generatorConfig.xml. 执行Generate MyBatis/iBATIS Artifacts代码生成成功
1.下载mybatis-generator-core-1.3.1-bundle,导入mybatis-generator-core-1.3.1.jar和myeclipse3.1.1.jar
2.编写生成器的配置文件generatorConfig.xml.
这个配置文件是生成器的主要文件,放在src目录下,这里只介绍基本的配置,具体介绍可以到官网查询
<?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="D:/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc5.jar" />
<context id="MBG" targetRuntime="MyBatis3">
<!-- 数据库配置 -->
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
userId="sys"
password="123456">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- model配置 -->
<javaModelGenerator targetPackage="com.common.model" targetProject="\MBGTestProject\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- xml配置文件 -->
<sqlMapGenerator targetPackage="com.common.model" targetProject="\MBGTestProject\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!--接口-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.common.dao" targetProject="\MBGTestProject\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table tableName="BASE_USERS" domainObjectName="Users" >
</table>
</context>
</generatorConfiguration>
在<table>里不要写schema属性,否则会报错,这个应该是mybatis-generator的bug
targetProject是项目的根路径,targetPackage是相应文件的包路径
3.执行generatorConfig.xml. 生成代码
在myeclipse10里右键单击generatorConfig.xml. 执行Generate MyBatis/iBATIS Artifacts代码生成成功
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
http://darrenzhong.com/?p=84 这里有插件的详细使用和安装教程 绝对原创
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询