1. First build the maven project, add the plugin
<build>
<plugins>
<plugin>
<!--Mybatis-generator plugin in pom.xml to automatically generate Mapper and POJO-->
<groupId>org.mybatis.generator </groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<!--location of configuration file-->
<configurationFile>maven_myibatis/mybatis-generator -config.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
2. Create a folder maven_myibatis under the project name, add the configuration file mybatis-generator-config.xml with the following content
<?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>
<!-- full path to local database driver jar package- ->
<classPathEntry location="E:/myIdea/mylib/ojdbc6.jar"/>
<context id="context" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="false"/>
< property name="suppressDate" value="true"/>
</commentGenerator>
<!-- Database configuration-->
<jdbcConnection driverClass="oracle.jdbc.OracleDriver"
connectionURL="jdbc:oracle:thin:@192.168.1.4:1521:yunboce"
userId="t4444" password="6666s"/>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 实体类生成的位置 -->
<javaModelGenerator targetPackage="com.tms.bean.system" targetProject=".\src\main\java">
<property name="enableSubPackages" value="false"/>
<property name="trimStrings" value="true"/> <!-- *Location of the Mapper.xml file-->
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.tms.mapper.system" targetProject=".\src\main\java">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- Mapper 接口文件的位置 -->
<javaClientGenerator targetPackage="com.tms.mapper.system" targetProject=".\src\main\java" type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- 相关表的配置 -->
<table tableName="manager"
enableCountByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
enableUpdateByExample="false"/>
</context>
</generatorConfiguration>
Note: the location of mybatis-generator-config.xml is determined according to the address defined by pom.xml
3. Click "maven projects" on the right, and then click "Mybatis-generator" to automatically generate code
Use the Mybatis-generator plugin to quickly generate code in idea
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326260732&siteId=291194637
Recommended
Ranking