src/main/java/com/itfsw/mybatis/generator/plugins/utils/IntrospectedTableTools.java
public static void setDomainObjectName(IntrospectedTable introspectedTable, Context context, String domainObjectName) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        // 配置信息（没啥用）
        introspectedTable.getTableConfiguration().setDomainObjectName(domainObjectName);

        // FullyQualifiedTable修正
        Field domainObjectNameField = FullyQualifiedTable.class.getDeclaredField("domainObjectName");
        domainObjectNameField.setAccessible(true);
        domainObjectNameField.set(introspectedTable.getFullyQualifiedTable(), domainObjectName);

        // 重新修正introspectedTable属性信息
        Method calculateJavaClientAttributes = IntrospectedTable.class.getDeclaredMethod("calculateJavaClientAttributes");
        calculateJavaClientAttributes.setAccessible(true);
        calculateJavaClientAttributes.invoke(introspectedTable);

        Method calculateModelAttributes = IntrospectedTable.class.getDeclaredMethod("calculateModelAttributes");
        calculateModelAttributes.setAccessible(true);
        calculateModelAttributes.invoke(introspectedTable);

        Method calculateXmlAttributes = IntrospectedTable.class.getDeclaredMethod("calculateXmlAttributes");
        calculateXmlAttributes.setAccessible(true);
        calculateXmlAttributes.invoke(introspectedTable);

        // 注意！！ 如果配置了ExampleTargetPlugin插件，要修正Example 位置
        PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class);
        if (configuration != null && configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE) != null) {
            String exampleType = introspectedTable.getExampleType();
            // 修改包名
            JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration();
            String targetPackage = javaModelGeneratorConfiguration.getTargetPackage();
            String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE));

            introspectedTable.setExampleType(newExampleType);
        }
    }
public static void setDomainObjectName(IntrospectedTable introspectedTable, Context context, String domainObjectName) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        // 配置信息（没啥用）
        introspectedTable.getTableConfiguration().setDomainObjectName(domainObjectName);

        // FullyQualifiedTable修正
        Field domainObjectNameField = FullyQualifiedTable.class.getDeclaredField("domainObjectName");
        domainObjectNameField.setAccessible(true);
        domainObjectNameField.set(introspectedTable.getFullyQualifiedTable(), domainObjectName);

        // 重新修正introspectedTable属性信息
        Method calculateJavaClientAttributes = IntrospectedTable.class.getDeclaredMethod("calculateJavaClientAttributes");
        calculateJavaClientAttributes.setAccessible(true);
        calculateJavaClientAttributes.invoke(introspectedTable);

        Method calculateModelAttributes = IntrospectedTable.class.getDeclaredMethod("calculateModelAttributes");
        calculateModelAttributes.setAccessible(true);
        calculateModelAttributes.invoke(introspectedTable);

        Method calculateXmlAttributes = IntrospectedTable.class.getDeclaredMethod("calculateXmlAttributes");
        calculateXmlAttributes.setAccessible(true);
        calculateXmlAttributes.invoke(introspectedTable);

        // 注意！！ 如果配置了ExampleTargetPlugin插件，要修正Example 位置
        PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class);
        if (configuration != null && configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE) != null) {
            String exampleType = introspectedTable.getExampleType();
            // 修改包名
            JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration();
            String targetPackage = javaModelGeneratorConfiguration.getTargetPackage();
            String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE));

            introspectedTable.setExampleType(newExampleType);
        }
    }
public static void setDomainObjectName ( IntrospectedTable introspectedTable , Context context , String domainObjectName ) throws NoSuchFieldException , IllegalAccessException , NoSuchMethodException , InvocationTargetException { // 配置信息（没啥用） introspectedTable . getTableConfiguration ( ) . setDomainObjectName ( domainObjectName ) ; // FullyQualifiedTable修正 Field domainObjectNameField = FullyQualifiedTable . class . getDeclaredField ( "domainObjectName" ) ; domainObjectNameField . setAccessible ( true ) ; domainObjectNameField . set ( introspectedTable . getFullyQualifiedTable ( ) , domainObjectName ) ; // 重新修正introspectedTable属性信息 Method calculateJavaClientAttributes = IntrospectedTable . class . getDeclaredMethod ( "calculateJavaClientAttributes" ) ; calculateJavaClientAttributes . setAccessible ( true ) ; calculateJavaClientAttributes . invoke ( introspectedTable ) ; Method calculateModelAttributes = IntrospectedTable . class . getDeclaredMethod ( "calculateModelAttributes" ) ; calculateModelAttributes . setAccessible ( true ) ; calculateModelAttributes . invoke ( introspectedTable ) ; Method calculateXmlAttributes = IntrospectedTable . class . getDeclaredMethod ( "calculateXmlAttributes" ) ; calculateXmlAttributes . setAccessible ( true ) ; calculateXmlAttributes . invoke ( introspectedTable ) ; // 注意！！ 如果配置了ExampleTargetPlugin插件，要修正Example 位置 PluginConfiguration configuration = PluginTools . getPluginConfiguration ( context , ExampleTargetPlugin . class ) ; if ( configuration != null && configuration . getProperty ( ExampleTargetPlugin . PRO_TARGET_PACKAGE ) != null ) { String exampleType = introspectedTable . getExampleType ( ) ; // 修改包名 JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context . getJavaModelGeneratorConfiguration ( ) ; String targetPackage = javaModelGeneratorConfiguration . getTargetPackage ( ) ; String newExampleType = exampleType . replace ( targetPackage , configuration . getProperty ( ExampleTargetPlugin . PRO_TARGET_PACKAGE ) ) ; introspectedTable . setExampleType ( newExampleType ) ; } }
设置DomainObjectName和MapperName
@param introspectedTable
@param context
@param domainObjectName
设置DomainObjectName和MapperName