From 2f8837b855ce8779552e8394d934be8e0bfe9d31 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:34:55 +0800
Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=B0=83=E6=95=B4=E5=85=B3?=
=?UTF-8?q?=E9=97=AD=20mybatis=20=E9=BB=98=E8=AE=A4=E7=9A=84=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=EF=BC=8C=E9=81=BF=E5=85=8D=20NoClassDefFoundError?=
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 | 35 ++++++++++++-------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/blade-starter-mybatis/pom.xml b/blade-starter-mybatis/pom.xml
index e7628cb..ea0c9a6 100644
--- a/blade-starter-mybatis/pom.xml
+++ b/blade-starter-mybatis/pom.xml
@@ -35,6 +35,7 @@
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 ca3776c..f4f66a0 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
@@ -41,10 +41,11 @@ 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;
/**
- * mybatisplus 配置
+ * mybatis plus 配置
*
* @author Chill
*/
@@ -110,20 +111,30 @@ public class MybatisPlusConfiguration {
}
/**
- * 关闭 mybatis 默认日志
+ * 内部类配置,避免 NoClassDefFoundError
+ *
+ * @author L.cm
*/
- @Bean
+ @Configuration
@ConditionalOnClass(MybatisPlusPropertiesCustomizer.class)
- 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);
+ 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);
+ }
}
- }
- };
+ };
+ }
+
}
}