删除mybatis生成mapper中多余导入的包

删除mybatis生成的mapper.java中多余导入的包,在PluginAdapter中获取导包集合clear后重新导入。

示例:

public class MergeablePluginAdapter extends PluginAdapter {

	public boolean validate(List<String> warnings) {
		return true;
	}

	@Override
	public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {
		sqlMap.setMergeable(false);
		return super.sqlMapGenerated(sqlMap, introspectedTable);
	}

	@Override
	public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass,
			IntrospectedTable introspectedTable) {
		Set<FullyQualifiedJavaType> importedTypes = interfaze.getImportedTypes();
		if (importedTypes != null) {
			importedTypes.clear();
		}
		FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(
				"GenericMapper<" + introspectedTable.getBaseRecordType() + "," + introspectedTable.getExampleType()
						+ "," + "java.lang.String" + ">");
		FullyQualifiedJavaType imp = new FullyQualifiedJavaType("com.xieyonghui.base.dao.GenericMapper");
		interfaze.addSuperInterface(fqjt);

		interfaze.addImportedType(imp);

		interfaze.getMethods().clear();
		interfaze.getAnnotations().clear();
		return true;
	}

}

说明:在clientGenerated方法中加入如下代码:

Set<FullyQualifiedJavaType> importedTypes = interfaze.getImportedTypes();
if (importedTypes != null) {
		importedTypes.clear();
}