给我写一个java程序,mybatis的拦截器的应用
时间: 2023-03-12 09:05:48 浏览: 117
我可以给你一个示例:import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;
import java.util.Properties;
@Intercepts({@Signature(type=Executor.class,method="update",args={MappedStatement.class,Object.class})})
public class MyInterceptor implements Interceptor {
public Object intercept(Invocation invocation) throws Throwable {
//拦截代码
return invocation.proceed();
}
public Object plugin(Object target) {
return Plugin.wrap(target,this);
}
public void setProperties(Properties properties) {
//设置参数
}
}
阅读全文