当数据库表字段和实体类的属性名称出现不匹配时:
当要表示如 显示用户是否在线等消息,,这类消息不在数据库中存储,但是在实体类中应用
默认查询会直接查询出所有数据,例如密码数据是不应该被查询的
问题描述:
解决:
知识点:
还可以在配置文件中 搞全局配置。。。
- spring:
- datasource:
- type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/www?serverTimezone=UTC
- username: root
- password: root
- main:
- banner-mode: off
-
- mybatis-plus:
- configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- global-config:
- banner: false
- db-config:
- table-prefix: tbl_
- id-type: assign_id
雪花算法:格式如下图
字段前加:@TableId(type = IdType.AUTO)
全局配置:
- spring:
- datasource:
- type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/www?serverTimezone=UTC
- username: root
- password: root
- main:
- banner-mode: off
-
- mybatis-plus:
- configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- global-config:
- banner: false
- db-config:
- table-prefix: tbl_ //全局配置实体类映射的数据库表前缀
- id-type: assign_id //全局配置数据库表中id的自增效果