首页 > 其他 > 详细

mybatis自动generator

时间:2017-09-17 21:45:34      阅读:320      评论:0      收藏:0      [点我收藏+]

 在pom.xml 新加

<plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.3.2</version>
    <configuration>
        <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>
        <verbose>true</verbose>
        <overwrite>true</overwrite>
    </configuration>
</plugin>

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="C:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.1.39\mysql-connector-java-5.1.39.jar" />

	<context id="context1" targetRuntime="MyBatis3">
		<jdbcConnection driverClass="com.mysql.jdbc.Driver"
			connectionURL="jdbc:mysql://127.0.0.1:3306/test" userId="root"
			password="huhanbo">
		</jdbcConnection>

		<!-- <javaTypeResolver> -->
		<!-- <property name="forceBigDecimals" value="false" /> -->
<!-- 	</javaTypeResolver> -->
		<!-- 实体定义地址 -->
		<javaModelGenerator targetPackage="com.me.mybatis.entity"
			targetProject="D:\Busys_Project\project\test\test\src\main\java" />
		<!-- sql的配置文件定义 -->
		<sqlMapGenerator targetPackage="mybatisMapper"
			targetProject="D:\Busys_Project\project\test\test\src\main\resources" />
		<!-- DAO定义 XMLMAPPER是xml的配置方式,还有ANNOTabelMapper的是注解方式 -->
		<javaClientGenerator targetPackage="com.me.mybatis.persistence"
			targetProject="D:\Busys_Project\project\test\test\src\main\java" type="XMLMAPPER" />

		<table tableName="company" domainObjectName="Company" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
	
	</context>
</generatorConfiguration>

  

配置好后,点击如下,就会在上面配置的对应目录生成  

技术分享

 

参考博客:

http://www.cnblogs.com/yjmyzz/p/mybatis-generator-tutorial.html

 

mybatis自动generator

原文:http://www.cnblogs.com/huhanbo/p/7537766.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!