使用mybatis生成配置文件bean、xml、dao
2016-08-07 09:34
489 查看
首先下载mybatis
下载解压后有lib目录
然后复制一个出来作为备份 然后src可能有示例文件 将其清空
然后修改generatorConfig.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 location="mysql-connector-java-5.1.25-bin.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://125.221.225.113/db_demao" userId="demao" password="demao">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="test.domain" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="test.mapping" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="test.IDao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="user_info_t" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
配置完成后选中lib文件夹按住shift 并右键点击lib目录,点击在此处打开命令窗口或按w键
在cmd中输入java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite 即可
邢台招聘 http://www.jinshixun.com/quanzhi/ kk06
下载解压后有lib目录
然后复制一个出来作为备份 然后src可能有示例文件 将其清空
然后修改generatorConfig.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 location="mysql-connector-java-5.1.25-bin.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://125.221.225.113/db_demao" userId="demao" password="demao">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="test.domain" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="test.mapping" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="test.IDao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="user_info_t" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
配置完成后选中lib文件夹按住shift 并右键点击lib目录,点击在此处打开命令窗口或按w键
在cmd中输入java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite 即可
邢台招聘 http://www.jinshixun.com/quanzhi/ kk06
相关文章推荐
- Mybatis 如何自动生成bean dao xml 配置文件 generatorconfig.xml (main()方法自动生成更快捷)
- Mybatis 如何自动生成bean dao xml 配置文件 generatorconfig.xml (mysql)
- Mybatis 如何自动生成bean dao xml 配置文件 generatorconfig.xml (main()方法自动生成更快捷)
- Mybatis 如何自动生成bean dao xml 配置文件 generatorconfig.xml
- 使用idea逆向代理自动生成mybaties的dao文件和配置xml
- 使用Mybatis-Generator自动生成Dao、model和mapper.xml相关文件
- 解决使用Oracle库利用MyBatis配置文件逆向生成的实体类时mapping.xml里有重复的节点问题
- 使用Mybatis-Generator自动生成Dao、model和mapper.xml相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- 使用dom4j从XML配置文件中生成菜单(一)
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- mybatis-generator自动生成dao、mapping、bean配置详解(转)
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- mybatis generator自动生成DAO、Bean、MapperXML等文件
- 使用generator自动生成Mybatis映射配置文件
- Mybatis使用generator自动生成映射配置文件信息
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- generator.xml文件自动生成mybatis的xml配置
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件