我发现在连接 mariadb 时生成的映射接口中缺少一些方法,映射器生成的内容如下:
public interface Mapper {
    int insert(Record record);
    int insertSelective(Record record);
}
应该是什么:
public interface Mapper {
    int deleteByPrimaryKey(Record id);
    int insert(Record record);
    int insertSelective(Record record);
    City selectByPrimaryKey(Record id);
    int updateByPrimaryKeySelective(Record record);
    int updateByPrimaryKey(Record record);
}
我尝试了几个不同的连接器库,包括 mysql-connector-java 和 mariadb-java-client。并且连接mysql时生成的代码是正确的,这提醒我mybatis generator 1.3.6是否不支持mariadb 5.7.20?顺便说一句,mysql的版本是5.7。这是我的 config.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="/maven/repo/org/mariadb/jdbc/mariadb-java-client/2.2.1/mariadb-java-client-2.2.1.jar" />
  <context id="mybatisgen" targetRuntime="MyBatis3">
    <commentGenerator>
      <property name="suppressAllComments" value="true" />
      <property name="suppressDate" value="true" />
    </commentGenerator>
    <jdbcConnection driverClass="org.mariadb.jdbc.Driver"
        connectionURL="jdbc:mariadb://127.0.0.1:3306/db?characterEncoding=utf8"
        userId="user"
        password="password">
    </jdbcConnection>
    <javaTypeResolver >
      <property name="forceBigDecimals" value="false" />
    </javaTypeResolver>
    <javaModelGenerator targetPackage="me.model" targetProject="src">
      <property name="enableSubPackages" value="true" />
      <property name="trimStrings" value="true" />
    </javaModelGenerator>
    <sqlMapGenerator targetPackage="me.mapper"  targetProject="src">
      <property name="enableSubPackages" value="true" />
    </sqlMapGenerator>
    <javaClientGenerator type="XMLMAPPER" targetPackage="me.dao"  targetProject="src">
      <property name="enableSubPackages" value="true" />
    </javaClientGenerator>
    <table tableName="test_table" domainObjectName="ATable" 
        enableCountByExample="false" enableUpdateByExample="false"
        enableDeleteByExample="false" enableSelectByExample="false"
        selectByExampleQueryId="false">     
    </table>
  </context>
</generatorConfiguration>