0

我试过Mybatis Generator,效果很好。但是,即使列名正确映射到驼峰式大小写,文件名(Mapper.xml、Client 和 Model)也不遵循驼峰式大小写。

因此,例如,表 TIPO_SERVICO 被映射到 Tiposervico/TiposervicoMapper 而不是 TipoServico/TipoServicoMapper。

我检查了 Mybatis Generator 文档,没有找到与表名大小写相关的属性。

Ps 我的数据库是甲骨文。

我的 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>
    <context id="context" targetRuntime="MyBatis3Simple">
        <commentGenerator>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>

        <jdbcConnection userId="[USER]" password="[PASSWORD]" driverClass="oracle.jdbc.OracleDriver" connectionURL="jdbc:oracle:thin:@[IP]:1521:[ENV]">
            <property name="remarksReporting" value="true"/>
        </jdbcConnection>

        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>

        <javaModelGenerator targetPackage="com.model" targetProject="src/main/java">
            <property name="enableSubPackages" value="false"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="com.mapper" targetProject="src/main/resources/META-INF">
            <property name="enableSubPackages" value="false"/>
        </sqlMapGenerator>

        <javaClientGenerator targetPackage="com.mapper" type="XMLMAPPER" targetProject="src/main/java">
            <property name="enableSubPackages" value="false"/>
        </javaClientGenerator>

        <table schema="patr" tableName="%" enableCountByExample="true" enableDeleteByExample="false"
               enableSelectByExample="true" enableUpdateByExample="false" >
            <domainObjectRenamingRule searchString="^Scm" replaceString="" />
        </table>
    </context>
</generatorConfiguration>
4

2 回答 2

1

为什么不手动配置呢?添加domainObjectName的属性

    <table schema="patr" tableName="TIPO_SERVICO" domainObjectName ="TipoServico" enableCountByExample="true" enableDeleteByExample="false"
           enableSelectByExample="true" enableUpdateByExample="false" >
        <domainObjectRenamingRule searchString="^Scm" replaceString="" />
    </table>
于 2018-08-14T06:57:46.560 回答
0

骆驼案例命名在评论 domainObjectRenamingRule 后再次起作用。

于 2018-08-15T11:00:22.460 回答