All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rexsheng.springboot.faster.system.config.MybatisConfig Maven / Gradle / Ivy

The newest version!
package com.github.rexsheng.springboot.faster.system.config;

import com.mybatisflex.core.audit.AuditManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;

@AutoConfiguration
@ConditionalOnClass(AuditManager.class)
public class MybatisConfig {

    private static final Logger logger = LoggerFactory
            .getLogger("mybatis-flex-sql");

    public MybatisConfig() {
        //开启审计功能
        AuditManager.setAuditEnable(true);

        //设置 SQL 审计收集器
        AuditManager.setMessageCollector(auditMessage ->
                logger.info("{}, {}ms", auditMessage.getFullSql().replaceAll("\r|\n"," ").replace("  "," ")
                        , auditMessage.getElapsedTime())
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy