abel533 / Mapper

Mybatis Common Mapper - Easy to use
https://mybatis.io
MIT License
7.29k stars 1.62k forks source link

处理通用方法出现IncompleteElementException #876

Open caippppppppppp opened 1 year ago

caippppppppppp commented 1 year ago

image processConfiguration 方法 image image image 如果在这过程中加载了其他mapper xml,映射中 resultMap 有extend属性的话,Configuration 类中buildAllStatements是有可能抛出异常的 image

caippppppppppp commented 1 year ago

image

建议通过Class<?> mapperInterface 获取所有方法名,拼接后通过Configuration类 getMappedStatement(String id, boolean validateIncompleteStatements) 获取MappedStatement

Method[] methods = mapperInterface.getMethods();
        for (Method method : methods) {
            try {
                String id = prefix + "." + method.getName();
                processMappedStatement(configuration.getMappedStatement(id, false));
            } catch (Exception e) {
                //ignore
            }
        }
abel533 commented 1 year ago

上面方法没有直接调用的地方,大部分都是:

/**
 * 配置完成后,执行下面的操作
 * <br>处理configuration中全部的MappedStatement
 *
 * @param configuration
 */
public void processConfiguration(Configuration configuration) {
    processConfiguration(configuration, null);
}

参数 mapperInterface 大部分情况都是 null,没法像你这样处理。