mybatis****(maven)-Eclipse

mybatis****(maven)-Eclipse

上面是****的一些项目路径

1.maven添加plugin
[html] view plain copy
  1. <!-- mybatis ****maven工具 -->  
  2.      <plugin>  
  3.                  <groupId>org.mybatis.generator</groupId>  
  4.                 <artifactId>mybatis-generator-maven-plugin</artifactId>  
  5.                     <version>1.3.2</version>  
  6.                     <dependencies>  
  7.                         <dependency>  
  8.                             <groupId>mysql</groupId>  
  9.                             <artifactId>mysql-connector-java</artifactId>  
  10.                             <version>${mysql.version}</version>  
  11.                         </dependency>  
  12.                     </dependencies>  
  13.                     <configuration>  
  14.                          <!--配置文件的路径-->  
  15.                          <configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>   
  16.                         <overwrite>true</overwrite>  
  17.                     </configuration>  
  18.            </plugin>  

2.添加jar包
[html] view plain copy
  1. <!--  mybatis****jar包 -->  
  2.     <dependency>  
  3.             <groupId>org.mybatis.generator</groupId>  
  4.             <artifactId>mybatis-generator-core</artifactId>  
  5.             <version>1.3.2</version>  
  6.         </dependency>  
  7.   
  8. 3.在resources目录下添加配置文件  
  9. <pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?>  
  10. <!DOCTYPE generatorConfiguration  
  11.   PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"  
  12.   "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">  
  13. <generatorConfiguration>  
  14.     <context id="test" targetRuntime="MyBatis3">  
  15.         <!-- 一些工具 -->  
  16.         <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin>  
  17.         <plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>  
  18.         <plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>  
  19.         <commentGenerator>  
  20.             <!-- 插入一个日期字段 -->  
  21.             <property name="suppressDate" value="true" />  
  22.             <!-- 注释 -->  
  23.             <property name="suppressAllComments" value="false" />  
  24.         </commentGenerator>  
  25.         <!--数据库链接 参数 -->  
  26.         <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
  27.             connectionURL="jdbc:mysql://localhost:3306/meedesk" userId="root"  
  28.             password="moshaoming">  
  29.         </jdbcConnection>  
  30.         <javaTypeResolver>  
  31.             <!-- This property is used to specify whether MyBatis Generator should   
  32.                 force the use of java.math.BigDecimal for DECIMAL and NUMERIC fields, -->  
  33.             <property name="forceBigDecimals" value="false" />  
  34.         </javaTypeResolver>  
  35.         <!-- 生成模型的包名和位置 -->  
  36.         <javaModelGenerator targetPackage="com.pts.meedesk.model"  
  37.             targetProject="src/main/java">  
  38.             <property name="enableSubPackages" value="true" />  
  39.             <property name="trimStrings" value="true" />  
  40.         </javaModelGenerator>  
  41.         <!-- 生成映射文件的包名和位置 -->  
  42.         <sqlMapGenerator targetPackage="com.pts.meedesk.mappers"  
  43.             targetProject="src/main/resources">  
  44.             <property name="enableSubPackages" value="true" />  
  45.         </sqlMapGenerator>  
  46.         <!-- 生成DAO的包名和位置 -->  
  47.         <javaClientGenerator type="XMLMAPPER"  
  48.             targetPackage="com.pts.meedesk.dao" targetProject="src/main/java">  
  49.             <property name="enableSubPackages" value="true" />  
  50.         </javaClientGenerator>  
  51.   
  52.         <!-- 要生成哪些表 -->  
  53.         <table tableName="User" domainObjectName="User"  
  54.             enableCountByExample="false" enableUpdateByExample="false"  
  55.             enableDeleteByExample="false" enableSelectByExample="false"  
  56.             selectByExampleQueryId="false"></table>  
  57.     </context>  
  58. </generatorConfiguration></pre><br>  
  59. 4.Run as->maven bulid->mybatis-generator:generate 执行 ->F5 刷新<br>  
  60. <br>  
  61. <pre></pre>  
  62. <br>  
  63. <br>