1、创建MyCommentGenerator类实现CommentGenerator接口
package gengrator; import org.mybatis.generator.api.CommentGenerator; import org.mybatis.generator.api.IntrospectedColumn; import org.mybatis.generator.api.IntrospectedTable; import org.mybatis.generator.api.dom.java.*; import org.mybatis.generator.api.dom.xml.TextElement; import org.mybatis.generator.api.dom.xml.XmlElement; import org.mybatis.generator.config.MergeConstants; import org.mybatis.generator.config.PropertyRegistry; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; import java.util.Set; import static org.mybatis.generator.internal.util.StringUtility.isTrue; /** * @Description: 修改注释 * @Author: * @CreateDate: 2019/1/16 16:38 */ public class MyCommentGenerator implements CommentGenerator { /** * properties配置文件 */ private Properties properties; /** * properties配置文件 */ private Properties systemPro; /* * 父类时间 */ private boolean suppressDate; /** * 父类所有注释 */ private boolean suppressAllComments; /** * 当前时间 */ private String currentDateStr; public MyCommentGenerator() { super(); properties = new Properties(); systemPro = System.getProperties(); suppressDate = false; suppressAllComments = false; currentDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()); } /** * @Description: 此方法返回格式化的日期字符串以包含在Javadoc标记中和XML注释。 * @Author: * @CreateDate: 2019/1/16 16:58 */ protected String getDateString() { String result = null; if (!suppressDate) { result = currentDateStr; } return result; } /** * @Description: 从该配置中的任何属性添加此实例的属性CommentGenerator配置。 * @Author: * @CreateDate: 2019/1/16 16:55 */ @Override public void addConfigurationProperties(Properties properties) { this.properties.putAll(properties); suppressDate = isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE)); suppressAllComments = isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS)); } /** * @Description: 为字段添加注释 * @Author: * @CreateDate: 2019/1/16 17:02 */ @Override public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); field.addJavaDocLine("/**"); sb.append(" * "); sb.append(introspectedColumn.getRemarks()); field.addJavaDocLine(sb.toString().replace(" ", " ")); field.addJavaDocLine(" */"); } /** * @Description: Java属性注释 * @Author: * @CreateDate: 2019/1/16 17:01 */ @Override public void addFieldComment(Field field, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); field.addJavaDocLine("/**"); sb.append(" * "); sb.append(introspectedTable.getFullyQualifiedTable()); field.addJavaDocLine(sb.toString().replace(" ", " ")); field.addJavaDocLine(" */"); } /** * @Description: 为模型类添加注释 * @Author: * @CreateDate: 2019/1/16 17:06 */ @Override public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } topLevelClass.addJavaDocLine("/**"); topLevelClass.addJavaDocLine("* @Description:"); topLevelClass.addJavaDocLine("* @Author: chf"); topLevelClass.addJavaDocLine("* @CreateDate: " + getDateString()); topLevelClass.addJavaDocLine("*/"); } /** * @Description: Java类的类注释 * @Author: * @CreateDate: 2019/1/16 16:52 */ @Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } innerClass.addJavaDocLine("/**"); innerClass.addJavaDocLine("* @Description:"); innerClass.addJavaDocLine("* @Author: chf"); innerClass.addJavaDocLine("* @CreateDate: " + getDateString()); innerClass.addJavaDocLine("*/"); } /** * @Description: 为类添加注释 * @Author: * @CreateDate: 2019/1/16 16:53 */ @Override public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean b) { if (suppressAllComments) { return; } innerClass.addJavaDocLine("/**"); innerClass.addJavaDocLine("* @Description:"); innerClass.addJavaDocLine("* @Author: chf"); innerClass.addJavaDocLine("* @CreateDate: " + getDateString()); innerClass.addJavaDocLine("*/"); } /** * @Description: 为枚举添加注释 * @Author: * @CreateDate: 2019/1/16 17:00 */ @Override public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); innerEnum.addJavaDocLine("/**"); sb.append(" * "); sb.append(introspectedTable.getFullyQualifiedTable()); innerEnum.addJavaDocLine(sb.toString().replace(" ", " ")); innerEnum.addJavaDocLine(" */"); } /** * @Description: 给getter方法加注释 * @Author: * @CreateDate: 2019/1/16 17:04 */ @Override public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {} /** * @Description: 给setter方法加注释 * @Author: * @CreateDate: 2019/1/16 17:07 */ @Override public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {} /** * @Description: 普通方法的注释,这里主要是XXXMapper.java里面的接口方法的注释 * @Author: * @CreateDate: 2019/1/16 17:03 */ @Override public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) { if (suppressAllComments) { return; } method.addJavaDocLine("/**"); method.addJavaDocLine(" * @Description: "); method.addJavaDocLine(" * @Author: chf"); method.addJavaDocLine(" * @CreateDate: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); method.addJavaDocLine(" */"); } /** * @Description: 给Java文件加注释,这个注释是在文件的顶部,也就是package上面。 * @Author: * @CreateDate: 2019/1/16 17:05 */ @Override public void addJavaFileComment(CompilationUnit compilationUnit) {} /** * @Description: Mybatis的Mapper.xml文件里面的注释 * @Author: * @CreateDate: 2019/1/16 16:54 */ @Override public void addComment(XmlElement xmlElement) { if (!this.suppressAllComments) { xmlElement.addElement(new TextElement("<!--")); StringBuilder sb = new StringBuilder(); sb.append("description "); sb.append(" chf "); String s = this.getDateString(); if (s != null) { sb.append(s); xmlElement.addElement(new TextElement(sb.toString())); } xmlElement.addElement(new TextElement("-->")); } } /** * @Description: 此方法为其添加了自定义javadoc标签。 * @Author: * @CreateDate: 2019/1/16 16:59 */ protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) { javaElement.addJavaDocLine(" *"); StringBuilder sb = new StringBuilder(); sb.append(" * "); sb.append(MergeConstants.NEW_ELEMENT_TAG); if (markAsDoNotDelete) { sb.append(" do_not_delete_during_merge"); } String s = getDateString(); if (s != null) { sb.append(' '); sb.append(s); } javaElement.addJavaDocLine(sb.toString()); } /** * @Description: 为调用此方法作为根元素的第一个子节点添加注释。 * @Author: * @CreateDate: 2019/1/16 17:06 */ @Override public void addRootComment(XmlElement xmlElement) {} public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> set) { } public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> set) { } public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> set) { } public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> set) { } public void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> set) { } }
2、配置generator.xml,修改其中的<commentGenerator>为如下形式:
<commentGenerator type="gengrator.MyCommentGenerator"> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <!-- <property name="suppressAllComments" value="true" /> --> </commentGenerator>
generator.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> <!--mysql 连接数据库jar 这里选择自己本地位置--> <!-- 注意,这里mysql的版本不能高于5 --> <classPathEntry location="C:/Users/CHEN/Downloads/MAVEN/.m2/repository/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar" /> <context id="testTables" targetRuntime="MyBatis3"> <commentGenerator type="gengrator.MyCommentGenerator"> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <!-- <property name="suppressAllComments" value="true" /> --> </commentGenerator> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/second_join_post_db" userId="####" password="####"> </jdbcConnection> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- targetProject:生成PO类的位置 src/main/java --> <javaModelGenerator targetPackage="entityqq" targetProject="src/main/java"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- targetProject:mapper映射文件生成的位置 如果maven工程只是单独的一个工程,targetProject="src/main/java" 若果maven工程是分模块的工程,targetProject="所属模块的名称",例如: targetProject="ecps-manager-mapperqq",下同--> <sqlMapGenerator targetPackage="mapperqq" targetProject="src/main/resources"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!-- targetPackage:mapper接口生成的位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="mapperqq" targetProject="src/main/java"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!-- 指定数据库表 --> <table domainObjectName="" tableName="person_basic_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_career_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_education_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_income_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_marriage_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_other" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_postal_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_profile_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="person_residence_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="prepare_person_info_record" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> <table domainObjectName="" tableName="reported_basic_record" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"><property name="useActualColumnNames" value="false"/></table> </context> </generatorConfiguration>
3、采用 main方法启动测试代码,自己写测试类
import org.mybatis.generator.api.MyBatisGenerator; import org.mybatis.generator.config.Configuration; import org.mybatis.generator.config.xml.ConfigurationParser; import org.mybatis.generator.internal.DefaultShellCallback; import java.io.InputStream; import java.util.ArrayList; import java.util.List; /** * @Description: 运行此方法生成mybatis代码 * 生成代码自动放入对应目录 * 配置文件targetProject应从项目名称开始到要生成到的classpath * @Author: * @CreateDate: 2019/1/16 17:26 */ public class MyBatisGeneratorRun { public static void main(String[] args) throws Exception{ MyBatisGeneratorRun app = new MyBatisGeneratorRun(); System.out.println(app.getClass().getResource("/").getPath()); app.generator(); System.out.println(System.getProperty("user.dir")); } public void generator() throws Exception{ List<String> warnings = new ArrayList<String>(); boolean overwrite = true; InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("generatorConfig.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(resourceAsStream); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); for(String warning:warnings){ System.out.println(warning); } } }
4、然后运行main方法,就会自动生成代码了,生成的代码如下:
package entityqq; import java.util.Date; /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ public class PersonBasicInfo { /** * 信息id,主键 */ private Long recordId; /** * 信息更新日期 */ private Date updateDate; /** * 客户姓名 */ private String name; /** * 证件类型 数据字典 */ private String idType; /** * 证件号码 */ private String idNo; /** * 报告时点说明代码(二代使用)数据字典 */ private String timePointCode; /** * 客户资料维护机构代码 暂不转换使用 */ private String customerDataFinanceCode; /** * 信息来源编码 */ private String sourceCode; /** * 信息报告日期 */ private Date reportDate; /** * 客户资料类型 */ private Integer clientInfoType; public Long getRecordId() { return recordId; } public void setRecordId(Long recordId) { this.recordId = recordId; } public Date getUpdateDate() { return updateDate; } public void setUpdateDate(Date updateDate) { this.updateDate = updateDate; } public String getName() { return name; } public void setName(String name) { this.name = name == null ? null : name.trim(); } public String getIdType() { return idType; } public void setIdType(String idType) { this.idType = idType == null ? null : idType.trim(); } public String getIdNo() { return idNo; } public void setIdNo(String idNo) { this.idNo = idNo == null ? null : idNo.trim(); } public String getTimePointCode() { return timePointCode; } public void setTimePointCode(String timePointCode) { this.timePointCode = timePointCode == null ? null : timePointCode.trim(); } public String getCustomerDataFinanceCode() { return customerDataFinanceCode; } public void setCustomerDataFinanceCode(String customerDataFinanceCode) { this.customerDataFinanceCode = customerDataFinanceCode == null ? null : customerDataFinanceCode.trim(); } public String getSourceCode() { return sourceCode; } public void setSourceCode(String sourceCode) { this.sourceCode = sourceCode == null ? null : sourceCode.trim(); } public Date getReportDate() { return reportDate; } public void setReportDate(Date reportDate) { this.reportDate = reportDate; } public Integer getClientInfoType() { return clientInfoType; } public void setClientInfoType(Integer clientInfoType) { this.clientInfoType = clientInfoType; } }
生成的Mapper如下:
package mapperqq; import entityqq.PersonBasicInfo; public interface PersonBasicInfoMapper { /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ int deleteByPrimaryKey(Long recordId); /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ int insert(PersonBasicInfo record); /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ int insertSelective(PersonBasicInfo record); /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ PersonBasicInfo selectByPrimaryKey(Long recordId); /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ int updateByPrimaryKeySelective(PersonBasicInfo record); /** * @Description: * @Author: * @CreateDate: 2019-01-16 18:35:49 */ int updateByPrimaryKey(PersonBasicInfo record); }
mapper.xml文件:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="mapperqq.PersonBasicInfoMapper"> <resultMap id="BaseResultMap" type="entityqq.PersonBasicInfo"> <!-- description 2019-01-16 18:35:49 --> <id column="record_id" jdbcType="BIGINT" property="recordId" /> <result column="update_date" jdbcType="DATE" property="updateDate" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="id_type" jdbcType="VARCHAR" property="idType" /> <result column="id_no" jdbcType="VARCHAR" property="idNo" /> <result column="time_point_code" jdbcType="VARCHAR" property="timePointCode" /> <result column="customer_data_finance_code" jdbcType="VARCHAR" property="customerDataFinanceCode" /> <result column="source_code" jdbcType="VARCHAR" property="sourceCode" /> <result column="report_date" jdbcType="DATE" property="reportDate" /> <result column="client_info_type" jdbcType="INTEGER" property="clientInfoType" /> </resultMap> <sql id="Base_Column_List"> <!-- description 2019-01-16 18:35:49 --> record_id, update_date, name, id_type, id_no, time_point_code, customer_data_finance_code, source_code, report_date, client_info_type </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!-- description 2019-01-16 18:35:49 --> select <include refid="Base_Column_List" /> from person_basic_info where record_id = #{recordId,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <!-- description 2019-01-16 18:35:49 --> delete from person_basic_info where record_id = #{recordId,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="entityqq.PersonBasicInfo"> <!-- description 2019-01-16 18:35:49 --> insert into person_basic_info (record_id, update_date, name, id_type, id_no, time_point_code, customer_data_finance_code, source_code, report_date, client_info_type) values (#{recordId,jdbcType=BIGINT}, #{updateDate,jdbcType=DATE}, #{name,jdbcType=VARCHAR}, #{idType,jdbcType=VARCHAR}, #{idNo,jdbcType=VARCHAR}, #{timePointCode,jdbcType=VARCHAR}, #{customerDataFinanceCode,jdbcType=VARCHAR}, #{sourceCode,jdbcType=VARCHAR}, #{reportDate,jdbcType=DATE}, #{clientInfoType,jdbcType=INTEGER}) </insert> <insert id="insertSelective" parameterType="entityqq.PersonBasicInfo"> <!-- description 2019-01-16 18:35:49 --> insert into person_basic_info <trim prefix="(" suffix=")" suffixOverrides=","> <if test="recordId != null"> record_id, </if> <if test="updateDate != null"> update_date, </if> <if test="name != null"> name, </if> <if test="idType != null"> id_type, </if> <if test="idNo != null"> id_no, </if> <if test="timePointCode != null"> time_point_code, </if> <if test="customerDataFinanceCode != null"> customer_data_finance_code, </if> <if test="sourceCode != null"> source_code, </if> <if test="reportDate != null"> report_date, </if> <if test="clientInfoType != null"> client_info_type, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="recordId != null"> #{recordId,jdbcType=BIGINT}, </if> <if test="updateDate != null"> #{updateDate,jdbcType=DATE}, </if> <if test="name != null"> #{name,jdbcType=VARCHAR}, </if> <if test="idType != null"> #{idType,jdbcType=VARCHAR}, </if> <if test="idNo != null"> #{idNo,jdbcType=VARCHAR}, </if> <if test="timePointCode != null"> #{timePointCode,jdbcType=VARCHAR}, </if> <if test="customerDataFinanceCode != null"> #{customerDataFinanceCode,jdbcType=VARCHAR}, </if> <if test="sourceCode != null"> #{sourceCode,jdbcType=VARCHAR}, </if> <if test="reportDate != null"> #{reportDate,jdbcType=DATE}, </if> <if test="clientInfoType != null"> #{clientInfoType,jdbcType=INTEGER}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="entityqq.PersonBasicInfo"> <!-- description 2019-01-16 18:35:49 --> update person_basic_info <set> <if test="updateDate != null"> update_date = #{updateDate,jdbcType=DATE}, </if> <if test="name != null"> name = #{name,jdbcType=VARCHAR}, </if> <if test="idType != null"> id_type = #{idType,jdbcType=VARCHAR}, </if> <if test="idNo != null"> id_no = #{idNo,jdbcType=VARCHAR}, </if> <if test="timePointCode != null"> time_point_code = #{timePointCode,jdbcType=VARCHAR}, </if> <if test="customerDataFinanceCode != null"> customer_data_finance_code = #{customerDataFinanceCode,jdbcType=VARCHAR}, </if> <if test="sourceCode != null"> source_code = #{sourceCode,jdbcType=VARCHAR}, </if> <if test="reportDate != null"> report_date = #{reportDate,jdbcType=DATE}, </if> <if test="clientInfoType != null"> client_info_type = #{clientInfoType,jdbcType=INTEGER}, </if> </set> where record_id = #{recordId,jdbcType=BIGINT} </update> <update id="updateByPrimaryKey" parameterType="entityqq.PersonBasicInfo"> <!-- description 2019-01-16 18:35:49 --> update person_basic_info set update_date = #{updateDate,jdbcType=DATE}, name = #{name,jdbcType=VARCHAR}, id_type = #{idType,jdbcType=VARCHAR}, id_no = #{idNo,jdbcType=VARCHAR}, time_point_code = #{timePointCode,jdbcType=VARCHAR}, customer_data_finance_code = #{customerDataFinanceCode,jdbcType=VARCHAR}, source_code = #{sourceCode,jdbcType=VARCHAR}, report_date = #{reportDate,jdbcType=DATE}, client_info_type = #{clientInfoType,jdbcType=INTEGER} where record_id = #{recordId,jdbcType=BIGINT} </update> </mapper>
pom.xml中相应的配置:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.kexin</groupId> <artifactId>chen</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.7</version> <configuration> <configurationFile>src/main/resources/generatorConfig.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.7</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.7</version> </dependency> </dependencies> </project>