This commit is contained in:
yulichang 2022-01-17 16:18:57 +08:00
parent 27093f321a
commit 798c956a6c

View File

@ -14,10 +14,10 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 拦截器配置类 如果配置了分页插件,可能会使拦截器失效 * 拦截器配置类 如果配置了分页插件,可能会使拦截器失效
@ -25,7 +25,6 @@ import java.util.List;
* *
* @author yulichang * @author yulichang
*/ */
@Order(Integer.MIN_VALUE)
@SuppressWarnings("SpringJavaAutowiredMembersInspection") @SuppressWarnings("SpringJavaAutowiredMembersInspection")
public class InterceptorConfig implements ApplicationListener<ApplicationReadyEvent> { public class InterceptorConfig implements ApplicationListener<ApplicationReadyEvent> {
@ -41,7 +40,7 @@ public class InterceptorConfig implements ApplicationListener<ApplicationReadyEv
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void onApplicationEvent(ApplicationReadyEvent event) { public void onApplicationEvent(ApplicationReadyEvent event) {
if (CollectionUtils.isNotEmpty(sqlSessionFactoryList)) { if (CollectionUtils.isNotEmpty(sqlSessionFactoryList) && Objects.nonNull(mpjInterceptor)) {
try { try {
for (SqlSessionFactory factory : sqlSessionFactoryList) { for (SqlSessionFactory factory : sqlSessionFactoryList) {
Field interceptorChain = Configuration.class.getDeclaredField("interceptorChain"); Field interceptorChain = Configuration.class.getDeclaredField("interceptorChain");