利用mybatis-generator自动生成JavaBean,mapping映射文件等
2014-10-16 12:44
381 查看
所需的资源: mybatis-generator-core-1.3.2.jar,mysql-connector-java-5.1.22-bin.jar。mybatis-generator-core-1.3.2.jar,官网访问太慢,你懂的。故已将jar文件免费上传,自行下载。
MyBatis :是支持定制化 SQL、存储过程以及高级映射的优秀的持久层框架。MyBatis 避免了几乎所有的 JDBC 代码和手工设置参数以及抽取结果集。MyBatis 使用简单的 XML 或注解来配置和映射基本体,将接口和
Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。
1、建立数据库表,新建文件夹src,存放文件。
2、创建XML配置文件generator.xml,使用的是mysql数据库。
3、执行jar文件。相同目录下执行命令行语句:java -jarmybatis-generator-core-1.3.2.jar
-configfile -generator.xml
4、MyBatis Generator finished successfully.完成。
MyBatis :是支持定制化 SQL、存储过程以及高级映射的优秀的持久层框架。MyBatis 避免了几乎所有的 JDBC 代码和手工设置参数以及抽取结果集。MyBatis 使用简单的 XML 或注解来配置和映射基本体,将接口和
Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。
1、建立数据库表,新建文件夹src,存放文件。
2、创建XML配置文件generator.xml,使用的是mysql数据库。
<?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用于设置数据库驱动包位置--> </pre><pre code_snippet_id="485664" snippet_file_name="blog_20141016_1_6249858" name="code" class="html"> <classPathEntry location="E:\ssh\lib\mybatis\mysql-connector-java-5.1.22-bin.jar"/> <!-- targetRuntime:代码生成目标,默认是MyBatis3--> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- 数据库连接的信息 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password=""> </jdbcConnection> <!-- 解决数据转换问题 --> <javaTypeResolver> <!--是否强制使用BigDecimal来表示所有的十进制和数值字段。--> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!--生成模型的包名和位置--> <javaModelGenerator targetPackage="project.model" targetProject="E:\ssh\lib\mybatis\src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!--生成的映射文件包名和位置--> <sqlMapGenerator targetPackage="project.mapping" targetProject="E:\ssh\lib\mybatis\src"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!--生成DAO的包名和位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="project.dao" targetProject="E:\ssh\lib\mybatis\src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!--要生成那些文件--> <!--<table tableName="表名" domainObjectName="类名"></table>--> <table tableName="t_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> </context> </generatorConfiguration>
3、执行jar文件。相同目录下执行命令行语句:java -jarmybatis-generator-core-1.3.2.jar
-configfile -generator.xml
4、MyBatis Generator finished successfully.完成。
相关文章推荐
- 利用Mybatis-Generator自动生成Dao、Model、Mapping等文件
- 利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- 利用mybatis_generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis-Generator自动生成映射配置文件和CRUD操作
- 使用generator自动生成Mybatis映射配置文件
- Mybatis使用generator自动生成映射配置文件信息
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用mybatis的generator自动生成映射文件
- eclipses利用Mybatis关联Mysql自动生成JavaBean和mybatis配置文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- Mybatis使用generator自动生成映射配置文件信息