import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
@Configuration
public class BatisPlusConfig {
@Bean
public String myInterceptor(SqlSessionFactory sqlSessionFactory) {
//实例化插件
ExamplePlugin sqlInterceptor = new ExamplePlugin();
//创建属性值
Properties properties = new Properties();
properties.setProperty("prop1","value1");
//将属性值设置到插件中
sqlInterceptor.setProperties(properties);
//将插件添加到SqlSessionFactory工厂
sqlSessionFactory.getConfiguration().addInterceptor(sqlInterceptor);
return "interceptor";
}
}
----------------------------------------------------------------------------
package com.comleader.goip.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org
mybatis或者mybatisplus自定义sql拦截插件(Interceptor)
最新推荐文章于 2024-03-23 07:11:56 发布