Mybatis 脱敏插件
最近在研究 Mybatis 的插件,所以考虑能不能在 ORM 中搞一搞脱敏,所以就尝试了一下,这里分享一下思路。借此也分享一下 Mybatis 插件开发的思路。
2.1 Mybatis 插件接口
Mybatis 中使用插件,需要实现接口org.apache.ibatis.plugin.Interceptor,如下所示:
public interface Interceptor {
Object intercept(Invocation invocation) throws Throwable;
default Object plugin(Object target) {
return Plugin.wrap(target, this);
}
default void setProperties(Properties properties) {
// NOP
}
}