调整关闭 mybatis 默认的日志,避免 NoClassDefFoundError

This commit is contained in:
卢春梦 2025-01-21 11:34:55 +08:00
parent f2dbad7986
commit 2f8837b855
2 changed files with 24 additions and 12 deletions

View File

@ -35,6 +35,7 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot-autoconfigure</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>

View File

@ -41,6 +41,7 @@ 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;
/**
@ -109,11 +110,19 @@ public class MybatisPlusConfiguration {
return new SqlLogInterceptor(properties);
}
/**
* 内部类配置避免 NoClassDefFoundError
*
* @author L.cm
*/
@Configuration
@ConditionalOnClass(MybatisPlusPropertiesCustomizer.class)
public static class MybatisPlusPropertiesCustomizerConfiguration {
/**
* 关闭 mybatis 默认日志
*/
@Bean
@ConditionalOnClass(MybatisPlusPropertiesCustomizer.class)
public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() {
return properties -> {
CoreConfiguration configuration = properties.getConfiguration();
@ -128,3 +137,5 @@ public class MybatisPlusConfiguration {
}
}