自动生成mybatis映射文件的方法
2014-09-03 14:18
501 查看
1,下载mybatis-generator-core-1.3.2.jar包
2,在当前界面打开cmd窗口
3,生成语句:java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite
4,generator.xml文件:
2,在当前界面打开cmd窗口
3,生成语句:java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite
4,generator.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:数据库的JDBC驱动的jar包地址--> <classPathEntry location="F:\API\jar包\mysql\mysql-connector-java-5.1.7-bin.jar" /> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/ndy" userId="root" password="123456"> </jdbcConnection> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver > <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- targetProject:自动生成代码的位置 --> <!--生成的模型的包名和位置--> <javaModelGenerator targetPackage="ndy.model" targetProject="G:\test_mybatis\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="true" /> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true" /> </javaModelGenerator> <!--生成的映射文件的包名和位置--> <sqlMapGenerator targetPackage="ndy.mapping" targetProject="G:\test_mybatis\src"> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!--生成DAO的包名和位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="ndy.dao" targetProject="G:\test_mybatis\src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 --> <table tableName="trole" domainObjectName="Role" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"></table> <table tableName="tuser" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"></table> <table tableName="tuser_trole" domainObjectName="UserRole" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"></table> </context> </generatorConfiguration>
相关文章推荐
- 命令+mybatis-generator插件自动生成Mapper映射文件
- mybatis自动生成映射文件实体类接口
- 使用mybatis的generator自动生成映射文件
- Mybatis使用generator自动生成映射配置文件信息
- mybatis自动生成mapper,dao,映射文件
- Mybatis使用generator自动生成映射配置文件信息
- java笔记之使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件2种方法
- MyBatis逆向工程自动生成实体类和映射文件
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis 如何自动生成bean dao xml 配置文件 generatorconfig.xml (main()方法自动生成更快捷)
- myeclipse自动生成可持久化类的映射文件的方法
- mybatis如何自动生成实体类,映射文件以及对应的dao层
- Mybatis使用generator自动生成映射配置文件信息
- 利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis 自动生成dao及映射文件
- mybatis自动生成mapper xml 映射 文件
- Mybatis使用generator自动生成映射配置文件信息
- 通过mybatis工具generatorConfig.xml自动生成实体,DAO,映射文件
- MyBatis之自动生成实体类及映射文件《二》