From 1eae535fd5566c0c2a5554a4df6634371b90cde8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com>
Date: Tue, 21 Jan 2025 11:45:47 +0800
Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=B0=83=E6=95=B4=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=20mybatis=20=E6=A8=A1=E5=9D=97=E4=BE=9D=E8=B5=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blade-starter-mybatis/pom.xml | 1 -
.../mp/config/MybatisPlusConfiguration.java | 39 +++++++------------
2 files changed, 13 insertions(+), 27 deletions(-)
diff --git a/blade-starter-mybatis/pom.xml b/blade-starter-mybatis/pom.xml
index ea0c9a6..e7628cb 100644
--- a/blade-starter-mybatis/pom.xml
+++ b/blade-starter-mybatis/pom.xml
@@ -35,7 +35,6 @@
com.baomidou
mybatis-plus-spring-boot-autoconfigure
- provided
org.mybatis
diff --git a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java
index f4f66a0..8ae0ba1 100644
--- a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java
+++ b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java
@@ -15,8 +15,8 @@
*/
package org.springblade.core.mp.config;
-import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties.CoreConfiguration;
+import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
@@ -27,8 +27,8 @@ import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.nologging.NoLoggingImpl;
import org.mybatis.spring.annotation.MapperScan;
import org.springblade.core.mp.intercept.QueryInterceptor;
-import org.springblade.core.mp.plugins.SqlLogInterceptor;
import org.springblade.core.mp.plugins.BladePaginationInterceptor;
+import org.springblade.core.mp.plugins.SqlLogInterceptor;
import org.springblade.core.mp.props.MybatisPlusProperties;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.constant.BladeConstant;
@@ -36,12 +36,10 @@ import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
/**
@@ -111,30 +109,19 @@ public class MybatisPlusConfiguration {
}
/**
- * 内部类配置,避免 NoClassDefFoundError
- *
- * @author L.cm
+ * 关闭 mybatis 默认日志
*/
- @Configuration
- @ConditionalOnClass(MybatisPlusPropertiesCustomizer.class)
- public static class MybatisPlusPropertiesCustomizerConfiguration {
-
- /**
- * 关闭 mybatis 默认日志
- */
- @Bean
- public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() {
- return properties -> {
- CoreConfiguration configuration = properties.getConfiguration();
- if (configuration != null) {
- Class extends Log> logImpl = configuration.getLogImpl();
- if (logImpl == null) {
- configuration.setLogImpl(NoLoggingImpl.class);
- }
+ @Bean
+ public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() {
+ return properties -> {
+ CoreConfiguration configuration = properties.getConfiguration();
+ if (configuration != null) {
+ Class extends Log> logImpl = configuration.getLogImpl();
+ if (logImpl == null) {
+ configuration.setLogImpl(NoLoggingImpl.class);
}
- };
- }
-
+ }
+ };
}
}