mybatis中maven使用生成控件

1 在pom.xml增加以下插件:

<plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
            </plugin>

2 src\main\resource中,建立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:\mysql-connector-java-5.1.32-bin.jar" />
  <context id="context1"  targetRuntime="MyBatis3">
    <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
     	 <plugin type="org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin"/>
      <commentGenerator>
			<property name="suppressAllComments" value="true" />
		</commentGenerator>
   
     <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
    connectionURL="jdbc:mysql://localhost:3309/mmsdata" 
    userId="root" password="38477000" />
       <javaTypeResolver>
      <property name="forceBigDecimals" value="true" />
    </javaTypeResolver>
       
    <javaModelGenerator targetPackage="com.itownet.isms.model" targetProject="src/main/java" />
      
   
   <sqlMapGenerator targetPackage="mappings" targetProject="src/main/java" /> 
         <table  tableName="notice" domainObjectName="notice"
			enableCountByExample="false" enableUpdateByExample="false"
			enableDeleteByExample="false" enableSelectByExample="false"
			selectByExampleQueryId="false"  >     
			</table>
  </context>
</generatorConfiguration>


3  然后就可以
在eclipse 中,选择pom.xml文件,击右键先择Run AS——>Maven Build… ——>在Goals框中输入:mybatis-generator:generate

猜你喜欢

转载自jackyrong.iteye.com/blog/2361526