mybatisplus各别字段不要驼峰
时间: 2023-11-08 13:05:03 浏览: 39
可以通过 Mybatis-plus 的全局配置来设置不要使用驼峰命名。具体来说,需要在全局配置中设置 dbColumnUnderline 为 true,然后在实体类的属性上使用 @TableField 注解来指定对应的数据库字段名即可。
示例代码如下:
```java
// 全局配置
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setDbColumnUnderline(true);
// 实体类
public class User {
@TableId(type = IdType.AUTO)
private Long id;
@TableField(value = "user_name")
private String userName;
private Integer age;
// 省略 getter/setter
}
```
相关问题
mybatisplus 各别数据查不出来
可能有以下原因导致:
1. 数据库中没有该数据。
2. 查询条件不正确,导致没有查出该数据。
3. 实体类与数据库表结构不匹配,导致无法查询。
4. 数据库连接配置错误,导致无法查询。
5. MyBatis-Plus 配置不正确,导致无法查询。
解决方法:
1. 确认数据库中是否有该数据。
2. 检查查询条件是否正确。
3. 确认实体类与数据库表结构是否匹配。
4. 检查数据库连接配置是否正确。
5. 检查 MyBatis-Plus 配置是否正确。