refactor: 封装公共配置,降低使用复杂度

This commit is contained in:
2023-11-25 20:45:16 +08:00
parent 4a8e4e4408
commit dafb2d8f5b
9 changed files with 123 additions and 0 deletions

View File

@@ -33,7 +33,9 @@ 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.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import top.charles7c.continew.starter.core.handler.GeneralPropertySourceFactory;
/**
* MyBatis Plus 自动配置
@@ -47,6 +49,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement(proxyTargetClass = true)
@EnableConfigurationProperties(MyBatisPlusExtensionProperties.class)
@ConditionalOnProperty(prefix = "mybatis-plus.extension", name = "enabled", havingValue = "true")
@PropertySource(value = "classpath:default-data-mybatis-plus.yml", factory = GeneralPropertySourceFactory.class)
public class MybatisPlusAutoConfiguration {
/**

View File

@@ -0,0 +1,17 @@
--- ### MyBatis Plus 配置https://baomidou.com/pages/56bac0/#%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE
mybatis-plus:
# 启动时是否检查 MyBatis XML 文件的存在默认false 不检查)
check-config-location: true
## MyBatis 原生支持配置
configuration:
# 是否开启自动驼峰命名规则camel case映射即从经典数据库列名 A_COLUMN下划线命名到经典 Java 属性名 aColumn驼峰命名的类似映射
# 此属性在 MyBatis 中原默认值为 false在 MyBatis-Plus 中,此属性也将用于生成最终的 SQL 的 select body如果您的数据库命名符合规则无需使用 @TableField 注解指定数据库字段名
map-underscore-to-camel-case: true
# MyBatis 自动映射时未知列或未知属性处理策略,通过该配置可指定 MyBatis 在自动映射过程中遇到未知列或者未知属性时如何处理
# NONE不做任何处理 (默认值)WARNING以日志的形式打印相关警告信息FAILING当作映射失败处理并抛出异常和详细信息
auto-mapping-unknown-column-behavior: NONE
# 日志配置
# 默认org.apache.ibatis.logging.slf4j.Slf4jImpl
# 更详细会有性能损耗org.apache.ibatis.logging.stdout.StdOutImpl
# 关闭(可单纯使用 p6spy 分析org.apache.ibatis.logging.nologging.NoLoggingImpl
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl