1 Star 0 Fork 0

9527 / springboot-mybatis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

springboot整合mybatis并配置log4j2打印sql以及调试信息。 一.mybatis有两种使用方式。一种是注解另外一只是配置mapper.xml

1.mybatis xml方式使用: @Mapper 在接口上添加@Mapper 注解,声明对应接口是一个Mapper.xml 声明xml里面对应的方法即可,最后service注入mapper。

2.注解方式使用 在接口上添加@Mapper 注解 * 传参方式: * 1> 使用@Param * 2> 使用Map * 3> 使用对象 * * 增删改查,MyBatis针对不同的数据库操作分别提供了不同的注解来进行配置: * @Insert * @Select * @Update * @Delete * * 具体详解请查看:http://www.mybatis.org/mybatis-3/zh/java-api.html */

返回结果的绑定 ,通过@Results 和@Result 来绑定

 *  通过情况下,没有配置的话,字段不相同的就不会对应上,同时如果配置了结果绑定时,部分字段没有对应的话,那么对应字段的值为null
 * **/

二.log4j2配置: SpringBoot默认使用了logback,所以要使用log4j2,要先去除spring boot的默认logging包

org.springframework.boot spring-boot-starter-web ${spring.boot.starter.version} org.springframework.boot spring-boot-starter-logging
添加spring-boot-starter-log4j2的依赖包
org.springframework.boot spring-boot-starter-log4j2 ${spring.boot.starter.version}
在application.properties中设置log4j2配置文件路径

logging.config=classpath:log4j2.xml

log4j2配置

Appenders:
    作用:定义日志输出位置(控制台、文件或其他)、内容结构(起始就是PatternLayout)、日志等级(不完全由Appenders确定)。
    不能做:哪些类使用该Appender
Loggers:
    作用:定义哪些类使用那些Appender,并可以设置日志级别

空文件

简介

springboot整合mybatis并配置log4j2打印sql以及调试信息。 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/yhditto/springboot-mybatis.git
git@gitee.com:yhditto/springboot-mybatis.git
yhditto
springboot-mybatis
springboot-mybatis
master

搜索帮助