使用mybatis命令工具生成映射文件
2017-01-16 00:00
337 查看
###如何通过 mybatis自动生成xml,dao,bean
###准备工具
mybatis-generator-core-1.3.2 工具jar包
mysql-connector-java-5.1.40 数据库连接jar包
mybatis-generate-config xml配置文件
###mybatis-generate-config
####注意: 在配置里面写的java 和resourse 目录必须存在也可以自己命名 ,工具放置好了
####生成文件,进入命令行输入相应得命令
###准备工具
mybatis-generator-core-1.3.2 工具jar包
mysql-connector-java-5.1.40 数据库连接jar包
mybatis-generate-config xml配置文件
###mybatis-generate-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="mysql-connector-java-5.1.40.jar"/> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressDate" value="true"/> <property name="suppressAllComments" value="true"/> </commentGenerator> <!--数据库链接地址账号密码--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/unitjy?useUnicode=true" userId="root" password="123456"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!--生成Model类存放位置--> <javaModelGenerator targetPackage="com.weibo.bean" targetProject="java"> <property name="enableSubPackages" value="true"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <!--生成映射文件存放位置--> <sqlMapGenerator targetPackage="com.weibo.mapping" targetProject="resourse"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!--生成Dao类存放位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.weibo.mapper" targetProject="java"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!--生成对应表及类名--> <table tableName="article" domainObjectName="Article" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="comment" domainObjectName="Comment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="label" domainObjectName="Label" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="label_article" domainObjectName="LabelArticle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="label_user" domainObjectName="LabelUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="menu" domainObjectName="Menu" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="role" domainObjectName="Role" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> <table tableName="menu_user" domainObjectName="MenuUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> </context> </generatorConfiguration>
####注意: 在配置里面写的java 和resourse 目录必须存在也可以自己命名 ,工具放置好了
####生成文件,进入命令行输入相应得命令
java -jar mybatis-generator-core-1.3.2.jar -configfile mybatis-generate-config.xml -overwrite
相关文章推荐
- 使用Mybatis生成工具自动生成实体类和对应的mapper映射文件以及接口文件
- Mybatis使用generator自动生成映射配置文件信息
- MyEclipse使用MyBatis Generator 工具逆向生成映射文件
- 使用工具生成mybatis所需文件
- 使用mybatis的generator自动生成映射文件
- 简单三步快速学会使用Mybatis-Generator自动生成entity实体、dao接口以及mapper映射文件(postgre使用实例)
- Mybatis使用generator自动生成映射配置文件信息
- 使用mybatis的generator自动生成po及mapper映射文件
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- hibernate 的 使用 MyEclipse 工具生成 POJO 类和映射文件*.hbm.xml
- Mybatis使用generator自动生成映射配置文件信息
- 命令+mybatis-generator插件自动生成Mapper映射文件
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- 使用 xsd.exe 命令工具将 xsd 架构生成 类(CS) 文件
- 在eclipse中使用MyBatis Geneator自动生成出对应数据库的实体与映射文件
- Mybatis使用generator自动生成映射配置文件信息