Springboot+ mybatis+ mysql配置@Slf4j


spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver # 驱动
    name: testDB # 配置名,可以随便写
    username: root # mysql用户名
    password: root # mysql密码
    type: com.alibaba.druid.pool.DruidDataSource # 连接池
    url: jdbc:mysql:///testDB?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true # url
mybatis:
  mapper-locations: classpath:mapper/*.xml # mapper文件路径
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 设置打印sql语句
logging:
  file: D:\\xy.log # 日志文件位置
  level:
    root: info # 日志级别

最简单的配置差不多就是这样了

使用:

@RestController
@Slf4j
public class TestController {
    @GetMapping("/test")
    public String test() {
        log.info("日志");
        return "";
    }
}

猜你喜欢

转载自www.cnblogs.com/liangyun/p/10594736.html