1:无论使用mybatis-plus还是mybatis,只要在springboot的配置文件—-appcation.yml中添加:就可以答应sql
logging:
level:
org.jeecg.modules.hdx.mapper: debug
org.jeecg.modules.hdx.mapper为@mapper注解下面的类,或者继承BaseMapper,或者@MapperScan扫描包的类
2:如果使用的是springboot+mybatis-plus的话
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
id-type: 4
# 默认数据库表下划线命名
table-underline: true
configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
2-1:在pom文件引入依赖
dependency>
groupId>com.baomidougroupId>
artifactId>mybatis-plus-boot-starterartifactId>
version>3.3.1version>
dependency>
3:如果使用的是springboot+mybatis的话(包含分页)
#数据库的配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mytest?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
username: root
password: root
#mybatis的配置
mybatis:
configuration:
# sql日志显示,这里使用标准显示
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 数据库中如果有类似 如 user_name 等命名,会将 _后的字母大写,这里是为了和实体类对应
map-underscore-to-camel-case: true
# 配置mapper文件的路径
mapper-locations: classpath:org/jeecg/modules/hdx.mapper/*/mapper/*.xml
#pageHelper配置分页(官网推荐配置)
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
3-1:pom配置(包含分页)
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-webartifactId>
dependency>
dependency>
groupId>org.mybatis.spring.bootgroupId>
artifactId>mybatis-spring-boot-starterartifactId>
version>2.0.1version>
dependency>
dependency>
groupId>mysqlgroupId>
artifactId>mysql-connector-javaartifactId>
scope>runtimescope>
dependency>
dependency>
groupId>org.projectlombokgroupId>
artifactId>lombokartifactId>
optional>trueoptional>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-testartifactId>
scope>testscope>
dependency>
!—pagehelper mybatis的分页插件依赖-->
dependency>
groupId>com.github.pagehelpergroupId>
artifactId>pagehelper-spring-boot-starterartifactId>
version>1.2.3version>
dependency>