springboot2.0 mybatis sql日志无法打印(已解决)

项目升级到springboot2.0之后,sql日志一直无法正常控制台打印,但是logback生成的日志文件正常
​​springboot2.0 mybatis sql日志无法打印(已解决)_第1张图片
sql语句都在在这里插入图片描述网上的方法都试用过了,也没有解决

  • 第一类,修改 日志级别
logging:
  level:
    com.huajie.mapper: DEBUG
  • 第二类,修改logback.xml文件
  • 第三类,修改jar包,配置log4j2
    这种很麻烦,要先排除springboot日志组件,再引入log4j2的jar
    再配置
mybatis:
    config-locations: classpath:mybatis/mybatis-config.xml
    mapper-locations: classpath:mybatis/mapper/*/*.xml
    type-aliases-package: com.eval
    configuration:
        cache-enabled: true
        lazy-loading-enabled: true
        multiple-result-sets-enabled: true
        default-executor-type: simple
        default-statement-timeout: 25000
        log-impl: org.apache.ibatis.logging.log4j2.Log4j2Impl

最后发现问题出在

日志组件冲突

项目中logback相关的配置注释掉就可以了,只用springboot自带的log日志jar包即可
springboot2.0 mybatis sql日志无法打印(已解决)_第2张图片
再配合 Mybatis Log Plugin 插件(可以将参数自动拼接到sql语句中),效果如下:
springboot2.0 mybatis sql日志无法打印(已解决)_第3张图片

你可能感兴趣的:(项目问题)