表名称未由Mybatis Generator映射到驼峰箱

时间:2018-07-30 18:33:02

标签: mybatis mybatis-generator

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

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

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

P.s。我的数据库是Oracle。

我的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>

2 个答案:

答案 0 :(得分:1)

为什么不手动配置它?添加 domainObjectName

的属性
    <table schema="patr" tableName="TIPO_SERVICO" domainObjectName ="TipoServico" enableCountByExample="true" enableDeleteByExample="false"
           enableSelectByExample="true" enableUpdateByExample="false" >
        <domainObjectRenamingRule searchString="^Scm" replaceString="" />
    </table>

答案 1 :(得分:0)

在对domainObjectRenamingRule进行注释之后,驼峰式命名再次起作用。